PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Jul 22, 2018 12:15 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun May 06, 2018 11:37 pm 
Offline
Forum Newbie

Joined: Sun May 06, 2018 11:34 pm
Posts: 1
I have checked my PHP ini file and display errors is set and also error reporting is E_ALL. I have restarted my Apache web server.

I have even put these lines at the top of my script, and it doesn't even catch simple parse errors. For example, I declare variables with a "$" and I don't close statements";". But all my scripts show a blank page on these errors, but I want to actually see the errors in my browser output.

error_reporting(E_ALL);
ini_set('display_errors', 1);

What is left to do?


Top
 Profile  
 
PostPosted: Mon May 07, 2018 5:49 pm 
Offline
Forum Newbie

Joined: Sun Jan 28, 2018 12:18 pm
Posts: 9
Go about it systematically:

First, make sure you are using the correct php.ini. PHP usually ends up giving you all sorts of php.ini, but the only one you should be worried about is the one which is linked to your Apache server.

I assume this is just on localhost, not a live site. Are you using Linux or Win? (..or maybe a Mac?) On Win if you're using WAMP, I remember the correct .ini file (that's hooked to Apache) is somewhere in the WAMP tray. If you're using Ubuntu the right one's here: /etc/php/7.0/apache2/php.ini (at least on my machine).

Go into the the ini file, do a search for and set these 4 directives:
Syntax: [ Download ] [ Hide ]
  1. error_reporting = E_ALL 
  2. display_errors = On 
  3. log_errors = On 
  4. ; No quotes: 
  5. error_log = /whatever/dir/you/prefer/php_errors.log 


Restart your Apache.

Then, for the sake of redundancy (these will override your php.ini directives), put these 4 functions at the top of your script:
Syntax: [ Download ] [ Hide ]
  1. ini_set("display_errors", "1"); 
  2. ini_set("log_errors", "1"); 
  3. ini_set("error_log", "/whatever/dir/you/prefer/php_errors.log"); 
  4. error_reporting(E_ALL); 


If this is working, you can figure out what's making it work through process of elimination, e.g., if it stops working when you comment out the ini_set("display_errors", "1") function, then you know you have the wrong php.ini file, etc.


Top
 Profile  
 
PostPosted: Wed May 09, 2018 9:54 am 
Offline
Forum Newbie

Joined: Sun Jan 28, 2018 12:18 pm
Posts: 9
..Or you could do it the easy way :)

Syntax: [ Download ] [ Hide ]
  1. phpinfo();  


This function gives you 'Loaded Configuration File', among others.

And you can always overwrite your php.ini settings per-directory:

https://blog.arvixe.com/setting-custom- ... r-website/


Attachments:
php-ini.png
php-ini.png [ 23.23 KiB | Viewed 555 times ]
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group