Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-05-2002, 08:46 PM   PM User | #1
ObiwanJebroni
New Coder

 
Join Date: Jun 2002
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
ObiwanJebroni is an unknown quantity at this point
Tutorials and Books

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 ) Thanks in advance.
__________________
-Obiwan Jabroni
May the Schwartz be With You
ObiwanJebroni is offline   Reply With Quote
Old 07-05-2002, 09:36 PM   PM User | #2
Nomadicus
New Coder

 
Join Date: Jul 2002
Location: Florida
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Nomadicus is an unknown quantity at this point
Thumbs up Tutorials

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.
Nomadicus is offline   Reply With Quote
Old 07-05-2002, 09:48 PM   PM User | #3
ObiwanJebroni
New Coder

 
Join Date: Jun 2002
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
ObiwanJebroni is an unknown quantity at this point
Thanks for the suggestion. And its a book too!! Bwahahaha, no more monitor! Hahahahahahaaaaaaaaaa...
__________________
-Obiwan Jabroni
May the Schwartz be With You
ObiwanJebroni is offline   Reply With Quote
Old 07-06-2002, 12:10 AM   PM User | #4
justlearning
New Coder

 
Join Date: Jun 2002
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
justlearning is an unknown quantity at this point
books

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.

JustLearning
__________________
~~~ Pretend that I have a long and creative signature. ~~~
justlearning is offline   Reply With Quote
Old 07-06-2002, 12:55 AM   PM User | #5
Nomadicus
New Coder

 
Join Date: Jul 2002
Location: Florida
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Nomadicus is an unknown quantity at this point
Globals ?

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.
Nomadicus is offline   Reply With Quote
Old 07-06-2002, 01:08 AM   PM User | #6
justlearning
New Coder

 
Join Date: Jun 2002
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
justlearning is an unknown quantity at this point
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.

JustLearning
__________________
~~~ Pretend that I have a long and creative signature. ~~~
justlearning is offline   Reply With Quote
Old 07-06-2002, 03:15 PM   PM User | #7
Jeewhizz
Regular Coder


 
Join Date: May 2002
Location: London, England
Posts: 369
Thanks: 0
Thanked 0 Times in 0 Posts
Jeewhizz is an unknown quantity at this point
there are several global variables in PHP:

------------------------------------------------------------------------------

$_SERVER
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).

$_GET
Variables provided to the script via HTTP GET. Analogous to the old $HTTP_GET_VARS array (which is still available, but deprecated).

$_POST
Variables provided to the script via HTTP POST. Analogous to the old $HTTP_POST_VARS array (which is still available, but deprecated).

$_COOKIE
Variables provided to the script via HTTP cookies. Analogous to the old $HTTP_COOKIE_VARS array (which is still available, but deprecated).

$_FILES
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.

$_ENV
Variables provided to the script via the environment. Analogous to the old $HTTP_ENV_VARS array (which is still available, but deprecated).

$_REQUEST
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.

$_SESSION
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.

------------------------------------------------------------------------------

$GLOBALS
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
------------------------------------------------------------------------------

Enjoy!

Jee
__________________
Jeewhizz - MySQL Moderator
http://www.sitehq.co.uk
PHP and MySQL Hosting
Jeewhizz is offline   Reply With Quote
Old 07-06-2002, 03:34 PM   PM User | #8
mordred
Senior Coder


 
Join Date: Jun 2002
Location: frankfurt, german banana republic
Posts: 1,848
Thanks: 0
Thanked 0 Times in 0 Posts
mordred is an unknown quantity at this point
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).

http://www.php.net/manual/en/languag...predefined.php

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.

@Nomadicus:
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.
mordred is offline   Reply With Quote
Old 07-06-2002, 08:40 PM   PM User | #9
Nomadicus
New Coder

 
Join Date: Jul 2002
Location: Florida
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Nomadicus is an unknown quantity at this point
Global variables

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.
Nomadicus is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:53 PM.


Advertisement
Log in to turn off these ads.