Hi,
I am still learning PhP. Cannot figure out how to hide error information from
showing up on the client side.
I have a Php file, which uses the function file_get_contents($url) to collect
data from another web site. Sometimes, the function call cannot succeed and
geneates error messages displayed on client-side distorting nicely laid-out pages.
I dont want any error messages to display on client side. I used the following
but it still displays error messages on the client side.
$html = file_get_contents($url) or die("");
How can I do it?
Forgive me if this is a stupid question.
Regards.
How to hide fuction errors from client-side?
Moderator: General Moderators
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
just put this on the top of everypage
I'm pretty sure that would do the job!
Code: Select all
error_reporting(0);Chris,
Thanks for your input. I started with your input and did some research and hope
to find a new way. In the php.ini file, I now change the value from On to Off
for the following parameter:
display_errors = Off
Could you please tell me whether the above will achieve the same results
as your solution?
In your suggestion, you used
error_reporting(0)
What constant corresponds to the value 0?
see http://us2.php.net/error_reporting. I am using php 5.0.4.
Do you think the php.ini solution may be better than putting
error_reporting(0) on every page?
Once again, thanks very much!
-David
Thanks for your input. I started with your input and did some research and hope
to find a new way. In the php.ini file, I now change the value from On to Off
for the following parameter:
display_errors = Off
Could you please tell me whether the above will achieve the same results
as your solution?
In your suggestion, you used
error_reporting(0)
What constant corresponds to the value 0?
see http://us2.php.net/error_reporting. I am using php 5.0.4.
Do you think the php.ini solution may be better than putting
error_reporting(0) on every page?
Once again, thanks very much!
-David
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
There are two directives that you could use to hide errors completely: error_reporting and display_errors. For local development I have error_reporting set to E_ALL (which reports absolutely everything that is not kosher with the script) and display_errors set to On. On my production servers I have error_reporting set to whatever level is necessary to maintain the site, but I almost always have display_errors set to Off. This is mainly for security and not so much for aesthetics.
These values can be set/changed at runtime with a call to ini_set...
These values can be set/changed at runtime with a call to ini_set...
Code: Select all
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', true); // or false to turn them off
?>- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida