在 file_get_contents 中,我在 GET 方法中调用了一个 php 文件,但它没有完全加载,当我手动调用 Url 时,它工作正常。
$checkedStatus = 1;
file_get_contents("https://test.com/pdf.php?checkedStatus='".$checkedStatus."'");
那是文件未完全加载,当我调用 file_get_contents() 时,但是当我手动调用 Url 时,它加载了我期望的内容!
尝试在代码中添加一些时间:
$ctx = stream_context_create(array('http'=>
array(
'timeout' => 20, //20 seconds (just for checking)
)
));
file_get_contents('https://test.com/pdf.php', false, $ctx);