We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Supress WARNING message when running PHP in Linux and re-run when error happen

duncanb7
duncanb7 asked
on
Medium Priority
395 Views
Last Modified: 2012-05-11
Dear Experts,

I would like to ask two question:
1-How  to suppress the Warning  such as "Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: htmlParseEntityRef: expecting ';' in http://www..............on Line 20" since it is more than 100 for such warning.
I don't find any option from man php command in Linux for switch-off the warning message . Any solution ?
2- how to make s simple script to re-run the php command once it has fatal error , any informatiion for that ?

Please advise

Duncan

Comment
Watch Question

Most Valuable Expert 2011
Author of the Year 2014

Commented:
Can't help you with number two - I've never wanted to design an app around tolerance for a fatal error.  But for the first one, you can use the @ notation:

Something like this...

$thing = @file_get_contents($url);
if ($thing === FALSE) echo "$url DID NOT WORK OUT WELL BUT WE SUPPRESSED THE ERROR";
RobOwner (Aidellio)
CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
If you want to suppress output warnings from loadHTMLFile($url), put an @ sign in front. This even works in:
<?php
$load = @$dom->loadHTMLFile($url);
?>

Open in new window

Author

Commented:
@, what is that mean? it works fine as you suggest, Why ? Please explain a little bit.
Thanks
Duncan
Owner (Aidellio)
CERTIFIED EXPERT
Most Valuable Expert 2015
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Thanks for your reply,

The second question might
go to new thread
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.