草庐IT

from_userid

全部标签

php - 将数据放入php ://input from command line

我有一个从php://input读取的小PHP脚本.使用我的命令行我可以运行脚本但我不知道如何“填充”php://input.我尝试使用phpfile.php但它填充了php://stdin不是php://input脚本可以总结为: 最佳答案 php://input仅适用于从网络服务器运行的脚本。当CLI脚本需要访问标准输入时,它们使用php://stdin,或者已经打开的流STDIN:或 关于php-将数据放入php://inputfromcommandline,我们在StackOve

PHP file_get_contents() : content truncated from 2147483648 to 2147483647 bytes

当我要创建2GB文件的zip文件时,如何找出问题。错误file_get_contents():contenttruncatedfrom2147483648to2147483647bytesFatalerror:Outofmemory(allocated2151677952)(triedtoallocate18446744071562067968bytes)in我正在使用专用服务器并且已经设置了memory_limit,max_execution_time,max_upload_filesize,max_post_size。但这对我不起作用。请检查我的代码并让我知道我做错了什么-创建新的

nginx - 错误 28105#0 : *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream

我无法使用php-fpm正确配置Nginx。当我得到任何php脚本时,我在浏览器中收到Nginx404Notfound错误:Filenotfound.在我的php-fpm日志中我得到:172.17.42.1-28/Apr/2015:09:15:15+0000"GET/index.php"404对于任何php脚本调用和Nginx日志,我得到:[error]28105#0:*1FastCGIsentinstderr:"Primaryscriptunknown"whilereadingresponseheaderfromupstream,client:127.0.0.1,server:loc

php - 拉维尔 5.1 : Get ID from firstOrNew method

我有以下功能,如果一个记录不存在,它会在数据库中创建一个新记录-如果一个存在,它会更新它。问题是它返回true,因此我无法获得插入或更新记录的ID。/***Savetimesheet.**@param$token*@param$data*/publicfunctionsaveTimesheet($token,$data){return$this->timesheet->firstOrNew($token)->fill($data)->save();} 最佳答案 先创建新模型然后保存,id会自动设置到模型中。/***Savetimes

php - 拉维尔 5.4 : Exclude a route with parameters from CSRF verification

根据Laravel5.4Docs,您可以通过将路由添加到VerifyCsrfToken中间件的$except属性来从CSRF验证中排除路由。但是出于某种原因,除非从主路由本身中排除,否则无法使用确切的路由名称排除带有参数的路由。预期排除的路线:protected$except=['main/{id}/sub/*'];仅适用于:protected$except=['main/*'];如何从CSRF验证中排除带有参数的路由? 最佳答案 因为在引擎盖下这个功能使用request()->is()方法,也许这对你有用:protected$ex

php - 使用 zend db 插入 .. select from ..

我有以下原始查询,它将商品从购物车移动到订单表:insertintowebshop_order_item(order_id,product_id,count)select1,product_id,countfromwebshop_cart我正在使用ZendDB进行所有建模。我想知道是否有一种方法可以在不使用原始查询的情况下实现上述查询的目标? 最佳答案 目前还没有办法从zenddb中的select插入。但是,如果您只需要一个适配器使用此功能,则可以使用类似于下面给出的方法:publicfunctioninsertSelect($ta

php - Twig (在 Symfony 中): access template parameters from twig extensions

我想从我的Twig扩展(过滤器、函数...)访问Twig模板参数而不显式传递它。我的所有twig扩展中始终需要一个“displayPreferences”变量,以便更改显示和转换值的方式。可以将此变量作为模板参数传递,并将其作为我运行的每个Twig过滤器/函数的参数传递,但这会使模板难以阅读。这样的东西会很棒:/***Twigfilter(renderadateusingtheuserdefinedformat)**@paramDate$date*/publicfunctionrenderUserDate($date){//Somehow,getatemplateparameter,w

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 日期格式() : 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