Do you know any collection of good PHP scripts and examples to use and learn from them?
From examples it can even be large good web apps like forums or CMS.
Goggling doesn't easily give the good sites.
Other questions/requests will follow later.
As side note, PHP has some many functions to see...
http://www.php.net/docs.php
As for existing code, just look at anything written in PHP. There is phpbb, drupal, phpmyadmin, piwik, etc... There isn't compiled PHP, so the source is the only way to run it.
What Kllrnohj said. Also, the only documentation I've ever needed to learn php functions and look up code is php.net/[function name], I urge you to commit that to muscle memory if you're planning on coding PHP.
KermMartian wrote:
What Kllrnohj said. Also, the only documentation I've ever needed to learn php functions and look up code is php.net/[function name], I urge you to commit that to muscle memory if you're planning on coding PHP.
This.
Aside from the occasional Google search about an issue, all I've ever used is php.net. I've used it since the very beginning and still do.
Thanks.
I downloaded the docs from php.net, which is great because I can see them when I don't have Internet access, and some php software. (the ones mentioned above, wikimedia and wordpress). I will check a (huge) list of php stuff that I found on smashing apps.
I also found that w3schools tutorials of PHP and references are incomplete but provided some easy examples.
I have some useful ideas to do in PHP and a lot to learn. It will be fun.
I might show the scripts to have feedback on what to improve early. This is probably going to happen in new year.
Is in PHP Regular Expressions (Perl-Compatible) any equivalent to the JavaScript:
rexpression = new RegExp("repeat","gi")
//comment: this is the same as regpression = /repeat/gi but with the advantage of allowing strings to be transformed into regular expressions
Also if possible I want a alternative that avoids eval(). With eval() I can do the trick in PHP and JavaScript too.
And about file upload how to make the server reject a file bigger than some arbitrary size? I don't want to rely on client-side check for file size...
LATE EDIT:
How do some sites mantain the url like "http://www.domain.com/" even when you are in any other pages in that "folder"?
Galandros wrote:
LATE EDIT:
How do some sites mantain the url like "http://www.domain.com/" even when you are in any other pages in that "folder"?
My best guess, as it's been many years since my PHP voyaging days, but the site is using a $_POST[''] method to direct you. Not sure how. But that's an educated guess on everything that I know about PHP.
Galandros wrote:
Is in PHP Regular Expressions (Perl-Compatible) any equivalent to the JavaScript:
rexpression = new RegExp("repeat","gi")
//comment: this is the same as regpression = /repeat/gi but with the advantage of allowing strings to be transformed into regular expressions
Also if possible I want a alternative that avoids eval(). With eval() I can do the trick in PHP and JavaScript too.
And about file upload how to make the server reject a file bigger than some arbitrary size? I don't want to rely on client-side check for file size...
LATE EDIT:
How do some sites mantain the url like "http://www.domain.com/" even when you are in any other pages in that "folder"?
For File Size limitations first look to php.ini, that has options for individual file sizes and max total POST data, second option for portibility is to use http://www.php.net/manual/en/function.filesize.php, that will check the filesize. If accepting uploaded files make sure they are not put up in a way that they are executable by the server so that users can not upload a malicious code file and then execute it, one way to do this is to put the uploads outside of the docroot, another is to block all requests to the folder, if they are needed for download then use readfile to return them.
Thanks for the answers so far.
bump
Could someone give an alternative answer to the clean url thing and reply to the regular expression thing, please? I couldn't found myself the answer on Internet so far...
Galandros wrote:
Thanks for the answers so far.
bump
Could someone give an alternative answer to the clean url thing and reply to the regular expression thing, please? I couldn't found myself the answer on Internet so far...
The "clean URL" thing (where the address appears to stay the same in the address bar, whichever page you visit) can be achieved using a frameset. I would advise you against using such a system, as it prevents people from linking to your site properly or adding it to their bookmarks/favourites.
PHP doesn't have a regular expression type, as such, it just uses strings. Take a look at the Perl Compatible Regular Expressions section on the PHP website.
Thank very much for the fast reply.
Some new search gave that some seem to use .htaccess and mod_rewrite to change url appearance. Better stay way for a while...
Actually clean URLs are entirely different from what you want. Clean URLs would be something like instead of:
http://www.cemetech.net/forum/viewtopic.php?t=3959
it is
http://www.cemetech.net/forum/viewtopic/t/3959
Notice the lack of an extension and GET parameters. Clean URLs are awesome. What you want isn't. To do clean urls in PHP requires using .htaccess and mod_rewrite.
Kllrnohj wrote:
Notice the lack of an extension and GET parameters. Clean URLs are awesome. What you want isn't. To do clean urls in PHP requires using .htaccess and mod_rewrite.
Technically that's on Apache, rather than with PHP. IIRF for IIS uses the same syntax as mod_rewrite, so is handy if you deploy sites to both web servers.
To hide the file name, for example:
http://example.com/folder/page.php to
http://example.com/folder/ they use the mod_rewrite too.
Framesets can achieve this, but it is disadvantageous, so I rarely use them.
benryves wrote:
Technically that's on Apache, rather than with PHP.
IIRF for IIS uses the same syntax as mod_rewrite, so is handy if you deploy sites to both web servers.
Who the hell would want to use IIS, much less PHP with IIS? The only reason to run IIS in the first place is for ASP.NET
I believe I found a PHP code alternative.
http://wiki.portugal-a-programar.org/php:htaccess
To change and surprisingly, a Portuguese resource.
And I don't understand yet what it does.
But with time I will discover, eventually... And without understanding, I can't figure if it is a good practise.
Just dragged this to discussion to know what you think about it.
Kllrnohj wrote:
benryves wrote:
Technically that's on Apache, rather than with PHP.
IIRF for IIS uses the same syntax as mod_rewrite, so is handy if you deploy sites to both web servers.
Who the hell would want to use IIS, much less PHP with IIS? The only reason to run IIS in the first place is for ASP.NET Or if you do development work on Windows, though there's nothing wrong with IIS these days. It's also much easier to set up than Apache (even easier now that Microsoft Web Platform exists). All you really need to do is unzip the PHP zip file somewhere, map .php to the PHP ISAPI DLL (a few mouse clicks), edit php.ini to load the modules you need and it "just works".
benryves wrote:
Or if you do development work on Windows, though there's nothing wrong with IIS these days. It's also much easier to set up than Apache (even easier now that
Microsoft Web Platform exists). All you really need to do is unzip the PHP zip file somewhere, map .php to the PHP ISAPI DLL (a few mouse clicks), edit php.ini to load the modules you need and it "just works".
If you do development work on Windows its still easier and better to use Apache. Run the Apache installer, run the PHP installer, and then it "just works" - no editing of ini's, no server configuration, nothing. So PHP with Apache is much easier to setup than IIS - no competition. Oh, and IIS still sucks.
Kllrnohj wrote:
benryves wrote:
Or if you do development work on Windows, though there's nothing wrong with IIS these days. It's also much easier to set up than Apache (even easier now that
Microsoft Web Platform exists). All you really need to do is unzip the PHP zip file somewhere, map .php to the PHP ISAPI DLL (a few mouse clicks), edit php.ini to load the modules you need and it "just works".
If you do development work on Windows its still easier and better to use Apache. Run the Apache installer, run the PHP installer, and then it "just works" - no editing of ini's, no server configuration, nothing. So PHP with Apache is much easier to setup than IIS - no competition. Oh, and IIS still sucks.
Or better yet, just download xampp.
Is that easy? Apache then PHP. I took a few hours of searching tutorials until found xampp, installed and some more time to discover the htdocs thing...
My error was I tried to install PHP without having Apache installed first.
The tutorials available didn't help me much, I don't know why.
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
»
Go to Registration page
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum