![]() Join Up! 96823 members and counting! |
|
|||
|
Software
Books
Each book purchase gives a couple bucks back to the PHP Development Team!
And there you have it. Because I specifically declared $REMOTE_ADDR to be a global variable
inside this function, I can now see it and echo it as if it were a local variable. I cannot
have access to global variables like $HTTP_USER_AGENT in that function, since I did not
declare it.
To call this function, I simply say:
And it will echo:
PHPBuilder.com
1
127.0.0.1
I use functions for commonly-used code in my pages. It's cleaner than simply using include to include the
same code over and over, although both will work. One very interesting use for functions is to build common features
on an HTML page, like your headers/footers.
There's a whole lot more that you can do with functions, and I won't mention it all here. This should be enough
to get you up and running.
|