• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 380
  • Last Modified:

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

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

0
duncanb7
Asked:
duncanb7
  • 2
  • 2
1 Solution
 
Ray PaseurCommented:
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";
0
 
RobOwner (Aidellio)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

0
 
duncanb7Author Commented:
@, what is that mean? it works fine as you suggest, Why ? Please explain a little bit.
Thanks
Duncan
0
 
RobOwner (Aidellio)Commented:
see here in the manual.  the "@" is used to suppress error and warning messages

http://au.php.net/manual/en/language.operators.errorcontrol.php
0
 
duncanb7Author Commented:
Thanks for your reply,

The second question might
go to new thread
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now