MAMP pro PHP Error handling grief - php

So mamp pro is all set up using PHP 5.3.6 / cache is XCache, error handling set to Display Startup errors - write to All errors and warnings - to set to Display and Log both checked.
restart the server, intentionally wrote some code that should bring up an error..
<?php
echo stupid;
?>
Yes this is all thats in the code.
I get nothing! No errors, only in the log.
I don't want to have my console open the entire time watching for errors, I want them printed on the screen.
The only way I can get this to work is by doing an INCLUDE on this code at the top of EVERY SINGLE PHP file.
error_reporting(E_ALL);
init-- yad yada ('display_errors', 'on');
From what I'm reading elsewhere, it seems like this is a big problem..
So how can I set up my mamp pro PHP.INI file to work properly and print directly to my browser?

I changed it in MAMP/bin/php/php5.3.6/conf/php.ini
You can change display_errors and display_startup_errors

Related

Not displaying errors in php

I am debugging some errors in my PHP bus booking site. My issue is that I am not able to display errors. When I googled this issue it shows you can achieve it though php.ini. But unfortunately I haven't find any php.ini file .
Now the error is showing as
This page isn’t working
cableandmedia.com is currently unable to handle this request. HTTP
ERROR 500
On your all-pages/or-a-common-file which-is-included-in-each-file.
On top just after starting <?php add these two lines:-
error_reporting(E_ALL);
ini_set('display_errors',1);
If you have php.ini file then check these two variables:-
display_errors
error_reporting
Now change these variables values to:-
display_errors=ON
error_reporting=E_ALL
Now save the file and restart your server(important if you are working on localhost).And you have good to go.
Add this line to your php file. To debug
ini_set('display_errors', 1);
error_reporting(E_ALL);

How to change a setting to true in a PHP file?

I have an Apache2 web server with PHP 5.5 installed.
My default PHP settings is display_error = 0 (I don't need globally displayed errors) but I need it on in specific PHP files.
I tried with:
error_reporting(E_ALL);
ini_set("display_errors", 1);
and it's not working.
Can someone tell me how can I make it show errors in specific PHP files?
i am try to force some error writing some no syntax logic and not showing error...
To show parse errors in PHP you have to put this on your php.ini
display_errors = on
My advice is to avoid displaying errors on production servers but log them all. So you can later inspect and fix bugs from yoursite-error.log file.
You should be concerned if your applications has warnings, errors etc. IMHO it is a bad idea to focus your attention only on few files instead of them all.
Although display_errors may be set at runtime (with ini_set()), it won't have any effect if the script has fatal errors. This is because the desired runtime action does not get executed.

how to display errors on MAMP?

I have MAMP, and I don't know how to display errors on it,
when I have error on my php code it shows only blank pages,
i have searched on Google, and I saw that I have to change it to display_errors = on on all of the folders and versions...
and include this on my page:
error_reporting(E_ALL);
ini_set('display_errors', 'on');
Stop your server.
Go to
Applications/Mamp/bin/php/phpVERSION/conf/php.ini
Set
error_reporting=E_ALL
display_errors=On
Start your server.
If this doesn't help - please post your phpInfo page.
This is how I got mine to display error:
Open MAMP
Click on Server tab
Click on PHP
Under Write, check All errors and warnings and Notices
Under To, check Display and Log
I am using MAMP with php version 7.0.6.
What I did was go to MAMP\conf\phpVERSION and open up the php.ini file there and change the display_errors value there to display_errors = On.
Once changed, restart your MAMP.

Errors not displaying in PHP 5.3

I recently upgraded to PHP 5.3.22 and now I'm getting WSODs whenever there are errors in my php code. I know I have display_errors disabled in php.ini, so I tried adding the following code to the top of my scripts to temporarily enable displaying errors on the screen for debugging.
error_reporting(E_ALL);
ini_set('display_errors', '1');
The above works if I have an undefined function but if I miss a semi-colon at the end of a line, it still displays a WSOD.
How can I get all errors to display on screen when I'm developing the scripts?
Enabling error reporting at run time like that fails to show fatals. You can enable it in your php.ini or add this to your htaccess to override it:
php_value display_errors 1
As the file cannot be parsed, setting the error level and display_errors inside the file is having no effect.
Set it in your php.ini

Enable errors in browser when parsing PHP-files

I recently changed to a MacBook and now use the MAMP-stack for development locally.
In my earlier development environment I always could see informative error-reports when I tried to access a PHP file through a web-browser and an error occurred. With the default installation of MAMP it seems that this feature is disabled, whenever I hit an error I can't see the cause of it, I can't even see a single line informing me that an error occurred.
Not until I start to debug the code in a debugger I can see where the error occurred.
Any idea how error reporting can be turned on?
I tried:
error_reporting(E_ALL);
No effect at all though.
reporting level to E_ALL and display errors on Include the following code at the top of every php file on in an include or require such as your config.php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
Try ini_set('display_errors', 'on');
You'll also want to check a phpinfo(), to see if the ini_sets are doing anything.
Or change "display_errors = Off" to "display_errors = On" in /Applications/MAMP/bin/php/php5.4.4/conf/php.ini
Navigate to MAMP settings (eg localhost:8889/MAMP)
Click PHP Tab
Find Log errors: setting
Tick to screen
Click Save

Categories