[thelist] single quotes and arrays
Garth Hagerman
hagerman at mcn.org
Sat Apr 23 19:51:53 CDT 2016
Hi everybody-
Since The List is alive again (hooray!), here's a query.
I've been making the same boo-boo over and over for years. I have a rote mechanical understanding of what to do about it, but I do not understand the conceptual background.
In PHP, I pass info to another page using a form. The page receiving the info has a line like this:
$pageid = $_GET[pageid];
This works, so there doesn't seem to be anything wrong, so I do it over and over and over. But it logs something like this into the error_log:
"PHP Notice: Use of undefined constant pageid - assumed 'pageid' ".
Since this happens a lot, the error_log gets to be a very large file.
So, I understand how to stop getting that notice: put single quotes around pageid.
But why? pageid isn't a string, it's the name of an array element. If I do the same single quote thing with other arrays, something like:
echo("<option value=\"$row['id']\">$row['title']</option>\n");
it's a fatal error and the whole page explodes.
I've tried to find a reasonable explanation online, but haven't found anything which makes the little "eureka!" light over my head light up.
Thanks in advance
Garth
* * * * * * * * * * * * * * * *
my online portfolio
http://garthhagerman.com/
More information about the thelist
mailing list