0

Possible Duplicate:
Can’t use method return value in write context

What is the way to add a if statement in Simple HTML dom parser( http://simplehtmldom.sourceforge.net/ ) function
Have a look at my script

include ('dom.php');
$check = file_get_html("http://www.google.com");
if(empty($check->find('div[id=domain]',0))){$same="NoData";} // line 3
else { $same = $check->find('div[id=domain]',0); }

Have a look at line 3! Here i want to add a if statement to check is there any div with the 'domain' attribute id at my targeted page! so, if it is empty that means that it has no div with the 'domain' attribute id so it should store NoData in $same variable. and if there is a div with the 'domain' attribute id then it will fetch the and store the name in $same variable. But // line 3 showing an ugly error!
Error: Fatal error: Can't use method return value in write context in C:\UwAmp\phpapps\uwamp\php\code.php on line 5
Any idea?

Community
  • 1
  • 1
Jessica Lingmn
  • 1,162
  • 3
  • 10
  • 15

1 Answers1

0

Probably hiding the error message is a solution if you want to hide the first error message(error message if there is no data at the targeted page while fetching)
so the if(); statement is not necessary!
Add this code to the first line of code before any function in your php script

error_reporting(0);
Max Muller
  • 533
  • 7
  • 18
  • *Hiding errors* is never a solution. – deceze Jan 17 '13 at 06:38
  • @deceze have a look at her last comment, i think she want to hide the error message if there is no div with the 'domain' attribute id at her targeted page.. – Max Muller Jan 17 '13 at 06:41
  • ***Hiding errors is never a solution.*** She has to check for the case where there is no domain attribute and handle it correctly, not let it generate an error which she ignores. – deceze Jan 17 '13 at 06:44