Page 1 of 1
Variables in PHP
Posted: Wed Nov 17, 2010 11:10 pm
by dheeraja
Hi Guys.
Right now I am working on a property site and I got there a variable $$link. So I want to know the difference between $link & $$link and also I want to know that what is the use of $_SERVER['DOCUMENT_ROOT'] variable.
Thank you.
Re: Variables in PHP
Posted: Wed Nov 17, 2010 11:33 pm
by s992
$$variable will declare a variable that is named as whatever $variable is. Kind of difficult to explain, let me show you:
Code: Select all
$variable = "hello";
$$variable = "this is my new variable"; // You can call this variable by using $hello, as you can see below:
echo $hello; // echoes "this is my new variable"
As for $_SERVER and other reserved variables, check out
the manual!
Re: Variables in PHP
Posted: Wed Nov 17, 2010 11:36 pm
by requinix
A variable variable takes the value of a variable and treats that as the name of a variable.
Variable variables
'DOCUMENT_ROOT'
The document root directory under which the current script is executing, as defined in the server's configuration file.
$_SERVER