草庐IT

file-uri

全部标签

php - file_get_contents 通过 php 失败,通过浏览器工作

我想要实现的目标:获取对API端点的请求,检索XML并随后解析结果。我正在发送一个file_get_contents请求来实现这一点。问题:`file_get_Contents`fails,error:Warning:file_get_contents(https://api.twitter.com/1.1/statuses/mentions_timeline.json):failedtoopenstream:Aconnectionattemptfailedbecausetheconnectedpartydidnotproperlyrespondafteraperiodoftime,o

PHP 多 cURL 性能比顺序 file_get_contents 差

我正在编写一个界面,我必须在其中启动4个http请求才能获取一些信息。我用两种方式实现了接口(interface):使用顺序file_get_contents。使用多curl。我已经用jmeter对2个版本进行了基准测试。结果表明,当jmeter中只有1个线程发出请求时,multicurl比顺序file_get_contents好得多,但当100个线程时更差。问题是:哪些因素会导致multicurl的性能下降?我的multicurl代码如下:$curl_handle_arr=array();$master=curl_multi_init();foreach($call_url_arra

javascript - 完成页面加载后调用 PHP DOM 函数 file_get_html

我们正在尝试从PHPDOM获取url,但我们尝试获取的webapge具有功能(页面加载后更改价格),所以现在我们需要PHPDOM功能file_get_html完成此远程页面的onload功能后获取HTML。$html=file_get_html('https://www.example.com');//Findallarticleblocksforeach($html->find('div.pad15h4a')as$article){echo$article->innertext.'';}foreach($html->find('p.sprcspan.fb')as$pr){echo$p

php - 为什么 php 将 $_FILES 值按名称、类型而不是输入文件名的顺序分组?

当我上传文件数组时,我得到以下数组。array(1){["upload"]=>array(2){["name"]=>array(2){[0]=>string(9)"file0.txt"[1]=>string(9)"file1.txt"}["type"]=>array(2){[0]=>string(10)"text/plain"[1]=>string(10)"text/html"}...}}以上述格式而不是以下格式接收的数组背后的原因(技术原因或任何好处)是什么?array(1){["upload"]=>array(2){[0]=>array(2){["name"]=>string(9)

php - php 的 file_get_contents 是否忽略文件锁定?

我已经阅读了php的manualpage关于“file_get_contents”函数,它没有说明“file_get_contents”在php文件锁定方面的行为方式。然而,在评论部分,用户Chris建议file_get_contentsdoesnotnormallyrespectPHP'sflocklocking,i.e.advisorylocking.Youcanworkaroundthiswithsomeextracodetorequestasharedlock,like...我测试成功了。我还测试了即使文件已被flock()锁定独家LOCK_EX可以让另一个php进程通过fil

php - 为什么要修改 REQUEST_URI?

当我在req.php中运行以下代码时:要求:curl"http://localhost/req.php/postcode/14482/city/./country/de/"我收到这样的回复:Request:/req.php/postcode/14482/city/country/de/当我在/city之后使用两个点时:Request:/req.php/postcode/14482/country/de/在/city之后加上三个点:Request:/req.php/postcode/14482/city/.../country/de/为什么REQUEST_URI被修改而不是原封不动地传递

php - 消息 : file_get_contents(sso. json):无法打开流:没有这样的文件或目录

我正在尝试手动从JSON文件中获取数据,而不是从URL中获取数据。我使用函数file_get_contents。我得到了错误:Message:file_get_contents(sso.json):failedtoopenstream:Nosuchfileordirectory即使路径是正确的。这是我的结构项目:->kalenderkerja->application->controllers->agendakerjaKalender.phpsso.json->assets->...这是我在user()函数中的代码Kalender.phppublicfunctionuser(){$ur

php - 如果找不到,我们如何使用 Apache 重定向到新的 HTML 静态内容并回退到旧的基于 CMS 的 PHP 版本? (nginx try_files)

问题:我们正在用Gatsby构建的SSGHTML版本替换旧的基于PHP的网站(基于Statamicv1)。问题是:只有一部分现有页面必须更换,而成员(member)空间、/login和/contact页面必须暂时保留。所以我想知道我应该如何使用新版本调整当前的.htaccess配置首先在特定目录中找到新的静态内容(public/)或者如果不是,则回退到旧的index.php?path=方法。注意事项:使用nginx这将通过try_files指令完成所以,这个问题在某种程度上与:https://serverfault.com/questions/290784/what-is-apache

php - 如何检查 file_get_contents 在 PHP 中返回 false 的原因

我试过这样做:$urls=array("https://www.gov.sg/");foreach($urlsas$url){d($url);//$url="http://www.google.com";$data=file_get_contents($url);d($data);}d()是一个类似于var_dump()的第3方函数。我不断收到$data=false。似乎域中的任何页面都在这样做。当我尝试另一个域(如google.com)时,它成功了。页面有效,我在浏览器上试过了。以下类似的帖子提出了URL编码问题,并启用了allow_url_fopen,但这些在此处并不适用:PHPf

php - Facebook - 无法使用 <input type ="file"> 标签上传文件

我试图让用户使用以下php从我的facebook应用程序上传图片MAX_SIZE*1024){$errors=2;}else{$image_name=md5(uniqid()).'.'.$extension;$newname="../images/".$image_name;$flName="/images/".$image_name;$copied=move_uploaded_file($_FILES['file1']['tmp_name'],$newname);if(!$copied){$errors=3;}}}}}if(isset($_POST['Upload'])&&$erro