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.
Related
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);
So really stuck at this point. My local environment which is using mamp will not display any errors at all.
I have established which php.ini it is loading so i am seeing the changes i am making changing in the phpinfo. But the log will no longer get generated and when i put dispaly_errors on as well nothing happens. Just blank screen.
settings below: (using mamp basic NOT pro)
error_reporting = E_ALL
display_errors = On
display_startup_errors = On
log_errors = On
error_log = "/Applications/MAMP/logs/php_error.log"
any help is appreciated. Driving me nuts :)
Thanks
/s
You can display errors by adding these lines directly in your PHP code:
ini_set('display_errors', 'On');
error_reporting(E_ALL);
For more details about errors handling you can read this post on my blog: Handle PHP errors and exceptions
For some reason my Mac is displaying the error message "Undefined index: an-undefined-key" whereas on Windows with WAMP it gracefully ignores the exception.
Example of usage:
if ($some_array['an-undefined-key']) {
// ...
}
Is there a PHP configuration which changes this behaviour?
I realise that I can do the following, but I would rather use the above technique if possible:
if (isset($some_array['an-undefined-key']) && $some_array['an-undefined-key']) {
// ...
}
Yes, you need to adjust the error_reporting and display_errors settings which sounds like they are different between your two different environments.
Here are links
error_reporting
PHP ini_set - look at first example for display_errors
The difference between the PHP on your Mac using the installed repo and your WAMP server is the php.ini, try editing your script and append the following lines to the top:
ini_set('display_errors', '1');
error_reporting(E_ALL);
This should be on your scripts. If this is not the problem, then please comment back and I will change accordingly.
You should not add unnecessary line to your script as you will have to change them when you go live.
Edit you php.ini ( using the wampmanager menus so you get the correct file )
left click wampmanager -> PHP -> php.ini
Look for these parameters and change to these values
error_reporting = E_ALL
This one makes error show on the web page
display_errors = On
error_log = "c:/wamp/logs/php_error.log"
this one will make the errors log into the file specified by error_log even if they dont show on the screen
log_errors = On
WAMP comes with XDEBUG configured so you should now see big orange errors in the web page
Check the bottom of the php.ini file for this line. Numbers for versions may differ on your system
; XDEBUG Extension
zend_extension = "c:/wamp/bin/php/php5.X.Y/zend_ext/php_xdebug-2.2.0-5.3-vc9.dll"
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
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