There are no E_NOTICE errors

php

#1

Hi, My PHP work space doesn’t alerts me when I user undefined array indexes or using uninitialized variables, normally it should trigger E_NOTICE but nothing like this happens. I check and trigger_error does work and I can see E_NOTICE error, so my error reporting is configured ok. I couldn’t find anything about it on google or on community.


#2

Hi,

I know too little of PHP to be of any real assistance, but I often experienced that explaining and narrowing down the issue helped me to actually fix things myself :slightly_smiling:

So here’s my 2 cts:

  1. Are you sure the error reporting is correct? trigger_error is not the same as actually having the error.
  2. Also, a snippet of code/link to running code in a workspace may help for others to step in and spot the issue.

Hope it helps :slightly_smiling:

Matthijs


#3

Seems lik php is ignoring what is set in php.ini located in workspace or /etc/php/apache2 or /etc/php/cli. And so only using “error_reporting(E_ALL)” in code takes effect.

As a code snipped I use simple one liner “$_POST[‘undefinedindex’]” that should result in “Notice: Undefined index: undefinedindex in…”

PHP info says
Configuration File (php.ini) Path /etc/php5/apache2
Loaded Configuration File /home/ubuntu/workspace/php.ini

But I set in both display_errors On and errors_reporting E_ALL. And nothing. (I do restart apache server everytime I change config files)

Edit: Ok, I noticed that /etc/php5/apache2/conf.d is mentioned as directory where php is loading additional inis from, and there is file called 80-c9.ini where error handling config is set to not displaying E_STRICT E_DEPRECATED and E_NOTICES, so I had to change it there and now it works as I wanted it to work. Sorry for bother.


#4

Thanks for posting the solution, surely someone will experience the same issue in the future and this will help.