在 PHP file_get_contents 中完全加载后获取文件

问题描述 投票:0回答:1

在 file_get_contents 中,我在 GET 方法中调用了一个 php 文件,但它没有完全加载,当我手动调用 Url 时,它工作正常。

$checkedStatus = 1;
file_get_contents("https://test.com/pdf.php?checkedStatus='".$checkedStatus."'");

那是文件未完全加载,当我调用 file_get_contents() 时,但是当我手动调用 Url 时,它加载了我期望的内容!

php file-get-contents
1个回答
0
投票

尝试在代码中添加一些时间:

$ctx = stream_context_create(array('http'=>
array(
    'timeout' => 20,  //20 seconds (just for checking)
)
));
file_get_contents('https://test.com/pdf.php', false, $ctx);
© www.soinside.com 2019 - 2024. All rights reserved.