Reputation: 23
Maybe someone could give me an idea, because I have not used php much until now. I installed a php web application on my local apache2 and got troubles with it, whereas many others pretend that the code is working for them.
Here is an example of what is done in the code. Ini files are used to store configurations. Lets call this one "my_config.cfg":
FOO=2
BAR=something
Now the code looks like the following:
$config = parse_ini_file("/opt/test/my_config.cfg", TRUE);
for ($i = 0; $i < $config[FOO]+1; $i++) {
..
}
Which is giving me an error about using a non declared constant. To make it work, I need to change the code to use quotes:
$config = parse_ini_file("/opt/test/my_config.cfg", TRUE);
for ($i = 0; $i < $config['FOO']+1; $i++) {
..
}
The question is, how can the above code work for others? In my opinion it should never work without quotes. I checked the whole code for define statements for "FOO" in the above case. There is none. So I am currently a little bit confused about that and wasn´t able to google anything on that topic.
Thanks for your help in advance.
Upvotes: 1
Views: 352
Reputation: 23
Ok, so that means the following log statement does not really matter:
[Thu Sep 14 22:50:00.595913 2017] [:error] [pid 8365] [client 192.168.0.128:50717] PHP Notice: Use of undefined constant SLM_ANZAHL - assumed 'SLM_ANZAHL' in /var/www/include/config.php on line 62
Because it treats it as 'SLM_ANZAHL' - right? Did not think of that, because it stated it as "error"
Upvotes: 1
Reputation: 781751
Read the error message, it says:
Notice: Use of undefined constant FOO - assumed 'FOO'
That means since there's no constant named FOO
, it treats $config[FOO]
as if you'd written $config['FOO']
-- it's trying to be helpful when you make mistakes like this.
If others have warnings disabled, they'll get the same behavior but no warning message.
Upvotes: 1