hno Posted February 4, 2010 Share Posted February 4, 2010 HI, When I want to write some php scripts I first write it in my localhost and check it using xampp and then transfer it to the host.But sometimes my scripts does not work well in the webserver and I understand that it should probably have some problems and errors but It doesn't show me.My question is this :How can print errors in webserver and makes the server to prints the errors? By the way,I have user error_reporting(1) but it doesn't make difference. Thanks Link to comment https://forums.phpfreaks.com/topic/190933-how-to-prints-error-of-the-script-in-webserver/ Share on other sites More sharing options...
$Three3 Posted February 4, 2010 Share Posted February 4, 2010 HI, When I want to write some php scripts I first write it in my localhost and check it using xampp and then transfer it to the host.But sometimes my scripts does not work well in the webserver and I understand that it should probably have some problems and errors but It doesn't show me.My question is this :How can print errors in webserver and makes the server to prints the errors? By the way,I have user error_reporting(1) but it doesn't make difference. Thanks You could try this: ini_set('display_errors', 1); You could put that at the beginning of your PHP scripts and this will turn error reporting on. The only problem with this solution is that if there are any syntactical errors in your script, your server still will not display any errors. The best solution is to edit your PHP.ini file and turn display_errors On. You could also try this: error_reporting(E_ALL); ini_set('display_errors', 1); This might be better than the first solution. Link to comment https://forums.phpfreaks.com/topic/190933-how-to-prints-error-of-the-script-in-webserver/#findComment-1006855 Share on other sites More sharing options...
roopurt18 Posted February 4, 2010 Share Posted February 4, 2010 You do not ever, ever, not in a million years, display_errors on a live production web site. So do not follow the suggestion given by $Three3. Instead look into set_error_handler(), which allows you to define your own error handling function. Then you can log the errors to a file that only you have access to. Or e-mail them to yourself. Or any number of alternative solutions that do not involve letting the general public and would-be hackers see the innards of your website. In all of my code, production or development, I have: ini_set( 'display_errors', 'off' ); error_reporting( 0 ); set_error_handler( 'my_own_error_handler' ); My users get to see nothing. Link to comment https://forums.phpfreaks.com/topic/190933-how-to-prints-error-of-the-script-in-webserver/#findComment-1006974 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.