我有两个页面
a.php<?php
 echo '1';
?>b.php$opts = array('http'=>array('method'=>"GET",'timeout'=>3,));
$context = stream_context_create($opts);
$open =file_get_contents("http://127.0.0.1/a.php", false, $context);
if($open=='1'){
echo '2'
}
为什么$open=='1' 为false?a.php改怎么写才能让$open=='1' 为true?

解决方案 »

  1.   

    是= 而不是==$open='1' ;if ($open){
    echo 'true';
    }
      

  2.   

    刚代码没出来,嘿嘿,现在看到你代码了。a.php修改成1即可.file_get_contents() 函数把整个文件读入一个字符串中。注意把整个文件读入一个字符串
      

  3.   

    请去确认 allow_url_fopen = On
      

  4.   

    楼主,我测试是没有问题的啊,$open=='1'是成立的。
      

  5.   

    亲测,没有问题,可能是你fopen没有打开