|
A PHP User - 05 Dec 2008
hello friends its very good to make it easy to learn some thing
Juan Francisco Giordana - 05 Dec 2008
$_GET = $_SERVER['HTTP_REFERER'];
echo '<a href="' . $_GET . '">Go back</a>.';
mystic@de4th.com: that example really sucks and you're only confusing people who is trying to learn.
This example has been taken from http://php.net/manual/en/language.variables.scope.php and demonstrates a better use of the global scope of a variable
<?php
$a = 1;
$b = 2;
function Sum()
{
global $a, $b;
$b = $a + $b;
}
Sum();
echo $b;
?>
That example should be deleted.
A PHP User - 05 Dec 2008
$_GET = $_SERVER['HTTP_REFERER'];
echo '<a href="' . $_GET . '">Go back</a>.';
mystic@de4th.com: that example really sucks and you're only confusing people who is trying to learn.
This example has been taken from http://php.net/manual/en/language.variables.scope.php and demonstrates a better use of the global scope of a variable
<?php
$a = 1;
$b = 2;
function Sum()
{
global $a, $b;
$b = $a + $b;
}
Sum();
echo $b;
?>
That example should be deleted.
A PHP User - 05 Dec 2008
$_GET = $_SERVER['HTTP_REFERER'];
echo '<a href="' . $_GET . '">Go back</a>.';
mystic@de4th.com: that example really sucks and you're only confusing people who is trying to learn.
This example has been taken from http://php.net/manual/en/language.variables.scope.php and demonstrates a better use of the global scope of a variable
<?php
$a = 1;
$b = 2;
function Sum()
{
global $a, $b;
$b = $a + $b;
}
Sum();
echo $b;
?>
That example should be deleted.
Juan Francisco Giordana - 05 Dec 2008
$_GET = $_SERVER['HTTP_REFERER'];
echo '<a href="' . $_GET . '">Go back</a>.';
mystic@de4th.com: that example really sucks and you're only confusing people who is trying to learn.
This example has been taken from http://php.net/manual/en/language.variables.scope.php and demonstrates a better use of the global scope of a variable
<?php
$a = 1;
$b = 2;
function Sum()
{
global $a, $b;
$b = $a + $b;
}
Sum();
echo $b;
?>
That example should be deleted.
bugScripts.us.tt - 05 Dec 2008
And for future reference, NEVER unset cookies by using unset($COOKIE);. The cookie will be resent on the next page, since that only unsets the cookie variable, not the actual cookie. Use setcookie('name', '', time());, this tells the cookie to expire immediately.
ZendURL - 05 Dec 2008
Here is an example:
If you have a signup sheet where a user fills out their name and password. So then on the next you could use $name = $_POST['name'], this would make $name be the same as the value that the user submitted. SO then you could add $name into your database, or show it to your user to allow him to confirm it.
Graham@namik.co.uk - 05 Dec 2008
What would be really helpfull is if there was a testing html file we could use with say, different form fields and a few buttons with which we could test variables and check the output. Sorry if that didn't make sense!
A PHP User - 05 Dec 2008
Another example of using SuperGlobals:
When completing a form, the data that is entered (name, phone, email...) is sent to the script via get or post mode.
In the script, you can access these informations with $_GET['name'], $_GET['phone'], etc (or, if the mode is post, with $_POST['name'], etc.)
And when uploading files, these files and informations about them are in the superglobal $_FILES.
mr.chew - 05 Dec 2008
I really don't understand how you use these superglobals in a website. I only grasped that they exist, but not how to use them.
mystic@de4th.com - 05 Dec 2008
Superglobals are extremely useful. Switching stylesheets on a website, message boards, some site navigations, and more are possible by super globals.
For example, you need your page to remember where the visitor came from so you can supply a link back to the page. You can do the following:
$_GET = $_SERVER['HTTP_REFERER'];
echo '<a href="' . $_GET . '">Go back</a>.';
That's not a very good example, since you'd want to check to see if $_GET is indeed the referer or not, but you get the point, no?
Cookies are what allows a site to remember your account name and/or password. They remember values for variables in a PHP script and fill them in when called.
Really, it's hard to explain any specific uses for them; they're very versatile and powerful.
Pzkpfw - 05 Dec 2008
You lost me here.
What do I use Superglobals for? Some examples of situations where Superglobals are used would help a lot.
As I read it now I just understand there exist something called Superglobals and that each of these variables has something to do with some other thing.
Kind Regards
Pzkpfw
Pzkpfw - 05 Dec 2008
You lost me here.
What do I use Superglobals for? Some examples of situations where Superglobals are used would help a lot.
As I read it now I just understand there exist something called Superglobals and that each of these variables has something to do with some other thing.
Kind Regards
Pzkpfw
A PHP User - 05 Dec 2008
When you use $_COOKIE['somevar'], you know that the value has come from a cookie on the user's machine, and not from someone editing the URL to your site. When using $_REQUEST['somevar'], however, you no longer have that guarantee, and you are left trusting the user to some extent.
This is not really true; a cookie can as easily be faked as an URL can be changed.
Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.
If you are reporting an error in the content, please tell me directly.
|