草庐IT

tt_content

全部标签

php - 如何加速 file_get_contents?

这是我的代码:$language=$_GET['soundtype'];$word=$_GET['sound'];$word=urlencode($word);if($language=='english'){$url="";}elseif($language=='chinese'){$url="";}$opts=array('http'=>array('method'=>"GET",'header'=>"User-Agent:"));$context=stream_context_create($opts);$page=file_get_contents($url,false,$co

PHP file_get_contents 忽略超时?

$url='http://a.url/i-know-is-down';//ini_set('default_socket_timeout',5);$ctx=stream_context_create(array('http'=>array('timeout'=>5,'ignore_errors'=>true)));$start=microtime(true);$content=@file_get_contents($url,false,$ctx);$end=microtime(true);echo$end-$start,"\n";我得到的响应通常是21.232段,应该不是大约5秒???

php - file_get_contents ('php://input' ) 总是返回一个空字符串

我正在构建一个PHPRESTfulAPI,遵循this教程。下面的函数,当使用'put'方法时,应该返回随请求发送的数据,每次都返回null:file_get_contents('php://input')。我什至下载并测试了教程中的完整代码示例,它仍然返回null。我正在使用cURL和以下命令来测试“put”方法:curl-i-XPUT-d'{"address":"SunsetBoulevard"}'http://localhost/clients/ryan.我已经在这上面浪费了很多天,但仍然没有得到它来读取json数据。我做错了什么? 最佳答案

php - Composer /WordPress : wp-content directory should or should not be committed

所以我最近开始在基于this的WordPress上使用Composer。教程。这是我的composer.json文件:{"repositories":[{"type":"package","package":{"name":"wordpress","type":"webroot","version":"4.3","dist":{"type":"zip","url":"https://github.com/WordPress/WordPress/archive/4.3.zip"},"require":{"fancyguy/webroot-installer":"1.0.0"}}}],"r

php - $_POST 与 $HTTP_RAW_POST_DATA 与 file_get_contents(php ://input)?

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:What’sthedifferencebetweenPOSTandrawPOSTinPHPatall?为了更好地理解,如果您能解释一下$_POST、$HTTP_RAW_POST_DATA和file_get_contents(php://输入)。什么时候使用哪个,为什么? 最佳答案 $_POST包含URL编码的(application/www-url-encoded)变量,这些变量会发布到您的脚本中,PHP会为您解码它们。处理HTMLFORM数据时会用到这个

PHP file_get_contents 返回 false

也许我坐在这里盯着这个看的时间太长了,但为什么file_get_contents会在这里返回false?我已经剪切并粘贴了URL,它工作正常吗?$url="http://jobs.github.com/positions.json?search=".$as_any."&location=".$location;//URLcontainshttp://jobs.github.com/positions.json?search=ProjectManager&location=Londonvar_dump($url);$json=file_get_contents($url);var_dum

php - 如何解决错误 "[ErrorException] file_get_contents(/var/www/laravel/.env): failed to open stream: No such file or directory"?

我在我的机器上使用Ubuntu14.04。我在文档根目录中安装了composer和laravel即/var/www我还授予了-R777文件夹laravel的权限,该文件夹存在于目录/var/www然后我使用cd/var/www/laravel进入目录laravel并运行以下命令phpartisan我看到了那里有所有可用的命令。然后我输入phpartisankey:generate得到了错误[ErrorException]file_get_contents(/var/www/laravel/.env):failedtoopenstream:Nosuchfileordirectory在这里

php - 如何在没有元 http-equiv=REFRESH CONTENT=time 的情况下几秒钟后在 PHP 中重定向页面

似乎不建议使用用于重定向,而是使用header('Location:url')但是,我想向用户显示一些消息,并在重定向之前让他们有时间阅读。有没有办法在没有元的情况下做到这一点? 最佳答案 尝试使用“刷新”标题:header('Refresh:3;url=page.php');另外,你可以看看这个问题RefreshHTTPHeader. 关于php-如何在没有元http-equiv=REFRESHCONTENT=time的情况下几秒钟后在PHP中重定向页面,我们在StackOverflo

php - 如何让 Laravel 将 View 的 "Content-Type" header 返回为 "application/javascript"?

我正在尝试使用[scriptsrc=""]标签输出一个动态javascript文件以从外部网站包含。由于View使用的是Blade引擎,因此它被呈现为text/html。我希望将此View的Content-Typeheader设置为application/javascript只是为了避免Chrome使用诸如“Resource解释为脚本但以MIME类型文本/html传输:"我的Controller:{//...returnView::make('embedded')->with('foo',$foo);}View本身:(function(jQuery){//appendstyleshee

php - PHP中file、file_get_contents和fopen的区别

我是PHP新手,我不太确定:file()、file_get_contents()和fopen()函数,什么时候应该使用其中一个? 最佳答案 前两个,file和file_get_contents非常相似。它们都读取整个文件,但file将文件读入数组,而file_get_contents将文件读入字符串。file返回的数组将由换行符分隔,但每个元素仍将附加终止换行符,因此您仍然需要注意这一点。fopen函数做一些完全不同的事情——它打开一个文件描述符,它作为一个流来读取或写入文件。它是一个低得多的函数,一个围绕Cfopen函数的简单包装