07-05-2002, 09:46 PM
Does anyone know where some good tutorials are on the web that I can learn PHP? Are there some good books out there as well? (I'd prefer books, since I've been on the computer for the last 4 weeks for 8 hours a day trying to finish this project, and I'd like to not be blind in another few weeks :p ) Thanks in advance.
07-05-2002, 10:36 PM
Check out Julie Meloni's "PHP Fast & Easy Web Development." It covers all the basics and also comes with Apache Web Server and MySQL. Once you install these, you'll be able to do all development offline, if you wish.
Meloni's style is clear and she gets right to the point, no tons and tons of egg head code to sift thru. And all the code works. I tested it. Just make sure you get the errata sheet from her web site.
07-05-2002, 10:48 PM
Thanks for the suggestion. And its a book too!! Bwahahaha, no more monitor! Hahahahahahaaaaaaaaaa...
07-06-2002, 01:10 AM
I tried Fast & Easy Web Development and was disappointed. The book was written back when the default setting was to have Globals enabled. When the admin installed PHP that I need to use, Globals were not enabled. I spent some time dealing trying to figure out why the examples did not work.
I understand that in August there will be a second edition with the proper settings, but I did not want to wait that long.
So far, one of the better books I have seen is Mastering PHP 4.1. (I lent it to someone so I don't remember the author or publisher.) It comes with a CD with PHP, MySQL, Apache in both Windows and Linux formats. It also has many of the examples on the CD.
Fast & Easy Web Development seemed like a simpler book (it is much smaller), but unless you already know about the $_POST and $_GET variables, it can be a bit confusing. It also comes with a CD, but since I borrowed this copy, the CD was missing so I don't know what is on it. Hopefully the second edition will be a bit easier to work with.
07-06-2002, 01:55 AM
The only globals that PHP supports are session variables.
I have asked many PHP developers just what these PHP globals are, but have never gotten an answer.
Also, most people do not run their own web servers. It's a lot easier to by space by the month. Mine only costs me $10. So I neither worry, nor do I have control over the PHP .ini file.
07-06-2002, 02:08 AM
One of the settings for PHP is the register_globals. With this function turned on, variables from forms using methods "GET" and "POST" are automatically registered when the next page is called. No need to use $variable = $_POST['variable']. Cookie variables are also automatically registered.
Prior to 4.1, this option was turned on by default. With 4.1 and later, this option was turned off by default. Having the register_globals on can be a security risk. The Fast & Easy Web Development book assumes that this option is turned on, and the examples did not explain how to read POST, GET and COOKIE variables with the register_globals off. I spent several days trying to figure out what was wrong with the examples in the book before someone explained to me the register_globals.
Hope that answers your question.
07-06-2002, 04:15 PM
there are several global variables in PHP:
Variables set by the web server or otherwise directly related to the execution environment of the current script. Analogous to the old $HTTP_SERVER_VARS array (which is still available, but deprecated).
Variables provided to the script via HTTP GET. Analogous to the old $HTTP_GET_VARS array (which is still available, but deprecated).
Variables provided to the script via HTTP POST. Analogous to the old $HTTP_POST_VARS array (which is still available, but deprecated).
Variables provided to the script via HTTP cookies. Analogous to the old $HTTP_COOKIE_VARS array (which is still available, but deprecated).
Variables provided to the script via HTTP post file uploads. Analogous to the old $HTTP_POST_FILES array (which is still available, but deprecated). See POST method uploads for more information.
Variables provided to the script via the environment. Analogous to the old $HTTP_ENV_VARS array (which is still available, but deprecated).
Variables provided to the script via any user input mechanism, and which therefore cannot be trusted. Note: when running on the command line, this will not include the argv and argc entries; these are present in the $_SERVER array. The presence and order of variable inclusion in this array is defined according to the variables_order configuration directive. This array has no direct analogue in versions of PHP prior to 4.1.0.
Variables which are currently registered to a script's session. Analogous to the old $HTTP_SESSION_VARS array (which is still available, but deprecated). See the Session handling functions section for more information.
Contains a reference to every variable which is currently available within the global scope of the script. The keys of this array are the names of the global variables
07-06-2002, 04:34 PM
Jeewhizz, your list of superglobals is certainly helpful for those still wondering in this thread, but I would only have to point out that when you quote from the manual, it's useful to include an URL to the specific manual page for further information (and to show others that your quotes come directly from the manual).
The link above should answer most questions still remaining. A lot of confusion, as was visible in this thread, comes from the circumstance that one thing was deactivating register_globals, and the other the introduction of the superglobals. Perhaps it's useful to note that the "super" means that these predefined variables are automagically available in any scope (means you don't have to use the keyword "global" any longer to make them available to a function etc.).
This behaviour is different from the $HTTP_POST_VARS etc. variables - if you use them for backward compatibility, you still have to manually import them into your function's scope.
I don't know the developers you asked, but if it's true what you say, they lack an immense amount of knowledge. I would refrain asking them again in future. Better search in the online manual or the changelog, or ask on the offical mailing lists, that should give you more and better insight into issues like these.
07-06-2002, 09:40 PM
Meloni lists these "global" variables as being held in the "global associative array $HTTP_POST_VARS or $HTTP_GET_VARS."
I think the confusion over this term global is due to the fact that, without sessions, there really is no such thing as a global variable (other than what was just mentioned) in PHP. IOW, unless you use sessions, or pass the variable from one page to the next as hidden, they don't exist.
Most old timers like myself frowned upon globals in languages like C++ or VB. Too many problems can arise when something is global, as any routine can access the variable. It's much better to put these in a class as private data. Then you can always give those routines that need to know access to the class.
When I first started programming in PHP3 we did not even have sessions. So I used an awful lot of hidden variables. I quickly discovered that programming for the web was quite different than apps programming for a PC.
Anyway, that's my 2 cents worth. Thanks to all for your input.