草庐IT

Contents

全部标签

php - 具有相对路径的 file_get_contents

我有以下目录结构。/var/www/base/controller/detail.php/var/www/base/validate/edit.json/var/www/html在/var/www/base/controller/detail.php中,如何使用file_get_contents()和相对路径来读取/var/www/base/validate/edit.json?我尝试了以下方法://failedtoopenstream:Nosuchfileordirectory(errorno:2)$json=file_get_contents('detail.php');//Noe

php - md5(file_contents_as_string) 会等于 md5_file(/path/to/file) 吗?

如果我这样做:...这会始终产生与以下相同的哈希值吗: 最佳答案 是的,它们返回相同:var_dump(md5(file_get_contents(__FILE__)));var_dump(md5_file(__FILE__));在我的情况下返回这个:string(32)"4d2aec3ae83694513cb9bde0617deeea"string(32)"4d2aec3ae83694513cb9bde0617deeea"编辑:看看这两个函数的源代码:https://github.com/php/php-src/blob/mast

php file_put_contents 函数不起作用

为什么file_put_contents会拒绝为以下代码工作?$f=file_put_contents("files/r.js","Sometexthere");if($f)print1;elseprint0; 最佳答案 可能是权限问题/files目录是否已更改为777?如果目录没有足够的权限,有时php将不允许您访问目录。不过我不知道空白错误。试试看是否有足够的权限,如果没有,则设置为777试试看。 关于phpfile_put_contents函数不起作用,我们在StackOverfl

PHP readfile 与 file_get_contents

我使用以下代码生成zip//pushtodownloadthezipheader('Content-type:application/zip');header('Content-Disposition:attachment;filename="'.$zip_name.'"');readfile($zip_name);这段代码运行良好,但由于未知原因在我尝试之前无法运行//pushtodownloadthezipheader('Content-type:application/zip');header('Content-Disposition:attachment;filename="'

php - file_put_contents、file_append 和换行符

我正在编写一个将数字添加到文本文件中的PHP脚本。我想在每一行都有一个数字,像这样:15812如果我使用file_put_contents($filename,$commentnumber,FILE_APPEND),结果如下:15812如果我添加一个像file_put_contents($filename,$commentnumber."\n",FILE_APPEND)这样的换行符,每个数字后都会添加空格,末尾有一个空行(下划线代表空格)):1_5_8_12___我如何获得该函数以我想要的方式添加数字,不带空格? 最佳答案 您是否尝

php - OPENSSL file_get_contents() : Failed to enable crypto

我正在构建一个个人股票平台(未分发)。我想要的一个组件是此页面上的EPS图:https://eresearch.fidelity.com/eresearch/evaluate/fundamentals/earnings.jhtml?stockspage=earnings&symbols=AAPL&showPriceLine=yes如你所见,页面是https,所以经过几天的努力,我启用了openssl,现在它似乎适用于所有https页面,例如facebook和twitter的主页,但它仍然无法满足我的需求。file_get_contents('https://facebook.com')

php - 为什么在使用 file_get_contents() 时出现 500 错误,但在浏览器中有效?

$html=file_get_contents("https://www.[URL].com");echo$html;在错误日志中产生这个:PHPWarning:file_get_contents(https://www.[URL].com)[function.file-get-contents]:failedtoopenstream:HTTPrequestfailed!HTTP/1.1500InternalServerErrorin/Applications/MAMP/htdocs/test.phponline13";但是,该网站在浏览器中运行良好。我也尝试过使用cURL。我在日志文

PHP ini file_get_contents 外部网址

我使用以下PHP函数:file_get_contents('http://example.com');每当我在某个服务器上执行此操作时,结果都是空的。当我在其他任何地方这样做时,结果就是页面的内容可能是什么。但是,当我在结果为空的服务器上在本地使用该函数时-无需访问外部URL(file_get_contents('../simple/internal/path.html');),它确实有效。现在,我很确定它与某个php.ini配置有关。然而,我不确定的是,哪个。请帮忙。 最佳答案 补充Aillyn的回答,您可以使用类似下面的函数来模

php - 什么更快? file_put_contents();打开();写入(); fclose();?

按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter指导。关闭10年前。什么更好?我有自己的MySQL日志,所以它大约有90MB,但我不确定应该使用哪一个。每次有查询要执行时,它都会打开文件。什么更快?

php - 使用 file_get_contents 发送 cookie

PHP手册中的示例展示了如何使用流上下文发送cookie。以下是摘录://Createastream$opts=array('http'=>array('method'=>"GET",'header'=>"Accept-language:en\r\n"."Cookie:foo=bar\r\n"));$context=stream_context_create($opts);//OpenthefileusingtheHTTPheaderssetabove$file=file_get_contents('http://www.example.com/',false,$context);如何