Jump to content

How to prints error of the script in webserver


hno

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.