草庐IT

content-encoding

全部标签

php - file_put_contents 不适用于 json laravel 和 php

我尝试了所有方法将项目推送到json文件中,但是当调用file_put_contents("file.json",$data)不起作用,页面关闭。这是我的Controller代码。publicfunctionaddJson(){$titulo=Input::get('title');$name=Input::file('image')->getClientOriginalName();$arr=json_decode(file_get_contents("js/data.json"),true);array_push($arr['galerias'],array('id'=>count

php - 更新 : Best practices for managing static content in Zend Framework?

我有一些关于Zend框架的问题。我正在尝试使用现在默认的displayAction()方法通过默认Controller路由所有静态页面。目的是让displayAction()通过查看page参数来处理请求,确定脚本页面是否存在,如果它确实呈现View,否则抛出404找不到页面错误。此外,还会进行测试以查看是否存在与参数同名的方法,如果存在,则调用该操作。此处列出的是来自application.ini的路由配置resources.router.routes.static-pages.route=/:pageresources.router.routes.static-pages.defa

curl - file_get_contents 和 curl 都不起作用

我刚刚使用file_get_contents来检索我网站中的数据。但它不返回任何内容。file_get_contents("https://www.google.co.in/images/srpr/logo11w.png")当我在本地环境中使用它时,它会返回值。我还在我的网站上尝试了curl以确定它是否返回任何内容。但它显示禁止您无权访问。我用谷歌搜索并找到了一些提示。我启用了allow_url_fopen和allow_url_include。但没有任何效果。我试过的curl代码functioncurl($url){$ch=curl_init();curl_setopt($ch,CUR

php - Content-disposition:inline header 不会显示内联图像?

我正在尝试在页面上内联显示图像。它由codeigniterController提供服务。classAssetextendsMY_Controller{functionindex($folder,$file){$asset="assets/$folder/$file";if(!file_exists($asset)){show_404();return;}switch($folder){case'css':header('Content-type:text/css');break;case'js':header('Content-type:text/javascript');break;

php stream_get_contents 在流的末尾挂起

Solutionattheendofthequestion我正在编写一个PHP应用程序,它向服务器发送消息,然后使用stream_get_contents读取响应。我以相同的方式与Android应用程序中的同一台服务器通信。android应用程序运行良好并且响应迅速,但是在从服务器读取响应时PHP挂起。在下面的代码示例中,我设置了一个5字节的微小缓冲区大小来测试理论。如果我删除这个缓冲区大小它会挂起,但是对于5字节大小它只会在最后一次通过循环时挂起:stream_set_timeout($this->socket,10);//10secondsreadtimeoutwhile(!feo

php - "Content-Type:text/plain"强制下载文件

如果我调用header('Content-Type:text/plain;charset=ISO-8859-15');浏览器将下载文件而不是显示它。使用text/html可以代替。(反正是处理下载的文件,不是下载源码)我尝试添加header('Content-Disposition:inline;');但它被忽略了。我对导致这个问题的原因一无所知,有什么提示吗?服务器是MAMP1.9.6(PHP5.3.5,Apache/2.0.64)。编辑:这只发生在Chrome上,它适用于Firefox、Camino和Safari。 最佳答案 我

php - 默认的 mb_internal_encoding() 值来自哪里?

如果我要编写一个新的php文件,并包含echo"currentmb_internal_encoding:".mb_internal_encoding(),输出值从何而来?它是如何“决定”/如何治理的?背景:我写了一个web应用程序,我认为我已经完成了将整个站点设置为utf-8的所有操作,但发现我仍然需要手动设置该值... 最佳答案 这取决于mbstring.internal_encodinginphp.ini的设置. 关于php-默认的mb_internal_encoding()值来自哪

php - 带有上下文的 file_get_contents() 使用 http/1.1 显着降低下载速度

使用下面的代码下载每张图片)file_get_contents())平均需要8-15秒......如果我不在file_get_contents()上使用上下文,则图像下载不到一秒。如果我将$opts更改为,下面我将获得与file_get_contents()相同的性能,而无需上下文,处理2,500张图像需要大约13秒x。$opts=array('http'=>array('protocol_version'=>'1.1','method'=>'GET','header'=>array('Connection:close'),'user_agent'=>'ImageResizer'));

php - 使用 file_get_contents() 时无法在 'þ' 上爆炸

我需要获取远程文件的内容,然后将这些内容分解为符号:“þ”。如果我分解的字符串只是一个局部变量,我可以让它工作,但我不能让它与file_get_contents()一起工作;$string='1þClassicLos1/10þþ15þ1þTrueþ2þCú';$parts=explode("þ",$string);var_dump($parts);结果:array(8){[0]=>string(1)"1"[1]=>string(16)"ClassicLos1/10"[2]=>string(0)""[3]=>string(2)"15"[4]=>string(1)"1"[5]=>strin

php - File_get_contents 不起作用?

我正在使用cakephp。我正在尝试使用file_get_contents从facebook获取数据。我收到警告。Warning(2):file_get_contents()[function.file-get-contents]:URLfile-accessisdisabledintheserverconfigurationWarning(2):file_get_contents(https://graph.facebook.com/XXXXXXX/?access_token=111978178XXXXXX|2.lg65A3c0atficNsFcf7Rog__.3600.12799X