[thelist] single quotes and arrays
Phil Parker
phil at lycosa.co.uk
Thu Apr 28 09:25:43 CDT 2016
Hi Garth,
Use single or double quotes to describe the elements of an array:
$_GET['page_id']
$_GET["page_id"]
You can use a variable or a constant to describe the array element:
$_GET[$foobar]
$_GET[CONSTANT]
What is happening in your situation is that you have asked PHP for the
GET array element as defined by the contents of the constant page_id.
This constant has not been defined, so PHP assumes the value of the
constant to be title of the constant, hence the warning. Because PHP has
therefore temporarily given the constant the value 'page_id' the script
returns the value $_GET['page_id'].
That is why you get the value you require, but also get an error.
Phil Parker
More information about the thelist
mailing list