dongpao5261 2013-01-17 05:33
浏览 32

添加if(); 在简单的HTML dom解析器函数中[重复]

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?

  • 写回答

1条回答 默认 最新

  • doufeng3602 2013-01-17 06:36
    关注

    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);
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度