草庐IT

optimizing-content-efficiency

全部标签

php - file_put_contents() : connect() failed: Permission denied in AWS server

$username_ftp="user";$password_ftp="password";$file_name="remote-transfer.txt";$url="example.biz/test/".$file_name;$hostname="ftp://$username_ftp:$password_ftp@$url";$content=file_get_contents('index.html');$options=array('ftp'=>array('overwrite'=>true));$stream=stream_context_create($options);f

php - 从 CURL 请求和 file_get_contents 收到的无效 cookie

我在尝试使用file_get_contents和curl捕获cookie时收到无效的cookie字符串。直接从浏览器浏览时收到的cookie是有效/事件的。但是,从file_get_contents和curl捕获的cookie似乎无效。我正在尝试像这样从file_get_contents中捕获$context=array('http'=>array('method'=>'GET','header'=>array('Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*\/*;q=0.8','User-Agent:Mo

php - Neo4j PHP Graphaware '400 Bad Content-Type header' 错误

下面的测试用例(假设密码正确)addConnection("default","http://neo4j:Password@localhost:7474")->build();$query="MATCH(u:User)RETURNu";$result=$client->run($query);$user=$result->firstRecord()->values()[0];?>给我以下错误:PHPFatalerror:UncaughtGuzzleHttp\\Exception\\ClientException:Clienterror:`POSThttp://neo4j:***@loc

PHP:XML 文件到字符串,使用 asXML() 更快的 file_get_contents 或 simplexml_load_file

我正在编写一个代理服务来缓存我的移动应用程序对网络服务的查询。(就像中间的一个人)我构建的代理站点的任务是将从应用程序获取的查询传递给第三方网络服务,并将第三方网络服务的响应保存为XML文件,并为所有后续调用从XML读取相同的查询文件并提供响应(基本上缓存响应-使用Php、curl和simplexml_load_file)。现在我的问题是-读取xml文件并返回字符串的推荐方法是什么。选项1:$contents=file_get_contents($filename);echo$内容;选项2:$xml=simplexml_load_file($文件名)echo$xml->asXML();

php - 如何从远程服务器使用 file_get_contents 后获取文件的 MIME 类型

我正在从Alfresco读取一个PHP文件,然后将其输出到浏览器。唯一的问题是mime类型或文件的扩展名。这是我正在使用的代码:我从get中收到文件名,因为我不知道如何从alfresco中获取文件名。但我必须以某种方式猜测mimetype。如果我在第一个字符中echo$cnt,就会提到它是PDF的事实(例如在屏幕上我看到%PDF-1.3%âãÏÓ20obj>/Type/XObject/Subtype/Image/Width2480/Height3508/BitsPerComponent1/ColorSpace/DeviceGray>>stream所以必须有一种方法可以通过函数从中获取m

php - file_get_contents - 连接超时

为什么浏览器会返回这个错误?Warning:file_get_contents(http://www.google.com)[function.file-get-contents]:failedtoopenstream:Connectiontimedoutin/home/test.phponline2 最佳答案 很可能您的服务器无法连接到外部资源,例如,由于防火墙限制。 关于php-file_get_contents-连接超时,我们在StackOverflow上找到一个类似的问题:

php - header ('Content-type: application/octet-stream' ) 导致 0 字节文件

我在PHP中使用数据库查询来检索二进制文件。但是当我试图强制下载它时,header('Content-type:application/octet-stream')行导致0字节文件。如果没有那一行,我可以下载包含完整内容的文件。这是肯定的二进制文件,所以我只是不明白为什么该行会导致问题。代码:$result=mysql_query("SELECTdataFROMstored_fileWHEREfile_name='$q'");while($row=mysql_fetch_array($result)){$file=$row['data'];}header('Content-dispos

PHP stream_context_create 和 HTTP header - 数组或字符串,\r\n 最后,Content-Length 可选?

我正在解决发送到远程站点的一些问题,特别是远程主机从不返回任何数据(空字符串)。在尝试解决任何其他问题之前,我想确保调用代码确实正确。代码是:$context=stream_context_create(array('http'=>array('method'=>"POST",'header'=>"Content-Type:application/xml",'timeout'=>60.0,'ignore_errors'=>true,#returnbodyevenifHTTPstatus!=200'content'=>$send_xml)));$response=trim(file_ge

php - 删除 apache 中的 Content-Type header

如何在apache中删除header内容类型?下面的代码不起作用header_remove('content-type'); 最佳答案 尝试这从响应中完全删除了Content-Typeheader。像你一样,使用header_remove()什么也没做Hereblur'sanswer在响应中给我留下了Content-Type:none。 关于php-删除apache中的Content-Typeheader,我们在StackOverflow上找到一个类似的问题:

php - file_get_contents 是否使用缓存?

我有一个函数可以生成一个包含数据库内容的表格。有些单元格具有自定义HTML,我正在通过模板系统使用file_get_contents读取它们。小内容是一样的,但这个Action可能执行了15次(我限制每页15行表格)。那么file_get_contents看到内容相同是否缓存? 最佳答案 file_get_contents()没有缓存机制。但是,您可以使用编写自己的缓存机制。这是草稿:$cache_file='content.cache';if(file_exists($cache_file)){if(time()-filemtim