草庐IT

dockerfile-from-image

全部标签

php curl 错误 : Failure when receiving data from the peer

我有一个基本的Curl脚本,它基本上在远程服务器上执行脚本。从大约6个月开始,我工作正常。昨天它停止工作,并返回以下错误。Curlerror:Failurewhenreceivingdatafromthepeer想知道是否有人知道curl在什么情况下会返回这样的错误? 最佳答案 当处理curl问题时,再次运行它:curl_setopt($ch,CURLOPT_VERBOSE,true);curl_setopt($ch,CURLOPT_STDERR,fopen('php://output','w'));通常准确的错误信息在某处。已修复

PHP Twig : access current template variable from within macro without passing?

是否可以从宏中访问当前模板的变量而不直接将变量传递给宏?谢谢。 最佳答案 可以将所有上下文变量传递给宏:{{macro(_context)}}_context是specialvariable,其中包含所有当前定义的变量(按名称=>值)。 关于PHPTwig:accesscurrenttemplatevariablefromwithinmacrowithoutpassing?,我们在StackOverflow上找到一个类似的问题: https://stackov

php - imagettftext() : calculate font size to ensure text fits image width

我正在使用imagettftext()在图像上写入动态文本,我希望它适合我的图像宽度。如何根据文本长度计算字体大小? 最佳答案 您可以在使用imagettfbbox函数输出之前计算TTF文本的边界框。遗憾的是,没有直接缩放以适合宽度的方法,因此您必须自己做。一种方法是将默认字体大小(例如20)的文本传递给imagettfbbox并从中检索宽度。然后,您可以通过计算比例因子来计算文本应该缩小或放大多少以适合您想要的大小:scale=targetWidth/bboxWidth;然后绘制合适大小的文字:fontSize=20*scale;

PHP 日期格式() : How to format date from string value

我有一点PHP代码:$exd=date_create('01Dec,2015');$exd=date_format($exd,'Y-m-d');echo$exd;用于格式化日期。预期输出为2015-12-01但它返回2016-12-01。我错过了什么? 最佳答案 首先使用createFromFormat方法,提供输入格式:$exd=DateTime::createFromFormat('dM,Y','01Dec,2015');//arguments(,)$exd=date_format($exd,'Y-m-d');//thencho

php - 自定义 wordpress 主题 : layout images not displaying

我正在构建一个自定义的wordpress主题。所以我的主题文件夹中包含以下文件/文件夹:header.phpindex.phpfooter.phpstyle.css/imagespicture-1.jpg我的问题是我无法在index.php、header.php和footer.php中使用imgTAG正确显示图像:[..]Generalinfo[..]图像存在并且如果被style.css引用则正确显示:.banner{background-image:url(images/picture-1.jpg);}我错过了什么吗?谢谢卢卡 最佳答案

php - Vagrant/Puppet --- 确保 : change from present failed: Could not set 'present on ensure: No such file or dir

我正在使用Vagrant和Puppet在Ubuntu上安装Apache和PHP。但是,我在vagrantup期间收到以下错误。我认为模板的路径是正确的,那为什么会出错呢?我正在使用设置here修改以确保apt-getupdate在任何其他操作之前运行错误←[1;35merr:/Stage[main]/Php/File[/etc/php5/apache2/apc.ini]/ensure:从缺席出席失败:无法设置“出席确保:没有这样的文件或目录ectory-/etc/php5/apache2/apc.ini.puppettmp_6187在/tmp/vagrant-puppet/module

php - 为什么我从 SagePay 收到错误 "4020 : Information received from an Invalid IP address."?

这是一个PHP(ZendFramework1.11)站点,未使用现成的软件包。当请求到:https://live.sagepay.com/gateway/service/vspserver-register.vsp(使用PAYMENT的TxType),我得到以下响应:4020:InformationreceivedfromanInvalidIPaddress.我已登录到SagePay管理区域并将实时服务器的IP地址添加到有效IP部分,我已确保它使用正确的SagePayURL发布到和。需要注意的是,这个问题是今天早上开始的,当时我们通过更改Vendor属性更改了接收付款的SagePay帐

php - 恐惧超时与 'mod_fcgid: read timeout from pipe'

我的应用程序尝试访问超时的URL有问题。我正在trycatch此超时并使用以下代码解决此问题:$timeout=120;if(false==$handle=@fsockopen($host,$port,$errno,$errstr,$timeout)){thrownewException("Couldnotconnecttourl:".$errstr);}$getRequest="GET{$url}HTTP/1.0\r\n";$getRequest.="Host:{$urlParts['host']}\r\n";$getRequest.="Connection:close\r\n\r\

PHP : Show the headers received from the browser

因此,当浏览器向服务器发出HTTP请求时,它采用一些header(get/post、cookies、host、UserAgent等)的形式。有没有一种方法可以在php脚本中读取和显示它们?是的,$_GET、$_POST和$_COOKIE都在那里。我正在寻找其余的标题信息。例如http://pgl.yoyo.org/http/browser-headers.php谢谢。 最佳答案 get_headers()功能是你要找的。如引用get_headers—Fetchesalltheheaderssentbytheserverinrespo

PHP/Zend : How to remove all chars from a string and keep only numbers

我只想保留数字并从变量中删除所有字符。例如:input:+012-(34).56.(ASD)+:"{}|78*9output:0123456789 最佳答案 这是一般的做法:$numbers=preg_replace('/[^0-9]+/','','+012-(34).56.(ASD)+:"{}|78*9');echo$numbers;输出:0123456789 关于PHP/Zend:Howtoremoveallcharsfromastringandkeeponlynumbers,我们在