草庐IT

c-set-offset

全部标签

php - 使用 ini_set() 的 PSR-1 兼容替代方案是什么?

我正在使我的代码库符合PSR-2标准(因此符合PSR-1标准),我遇到了以下代码:publicfunctioninit(){parent::init();//AllowALargerPHPMemoryLimitForThisScriptini_set("memory_limit","512M");//AllowALargerScriptExecutionLimitForThisScriptini_set('max_execution_time',300);}用于增加此特定脚本(仅供站点管理员访问且不经常运行)能够消耗的内存量和执行时间。在php.ini中设置默认的memory_limi

PHP : session variable having an undefined offset error

我是PHP编程的新手。我正在创建一个带有session的简单登录表单。我传递了两个session变量:$_SESSION['username']和$_SESSION['logon'].这是我的代码:$rowcount=mysqli_num_rows($result);if($rowcount==1){session_start();$_SESSION['logon']=="online";$_SESSION['username']=$username;header("location:../index.php?username=$_SESSION[username]");}问题是,当我

php - codeception : Setting the "doctrine" pre-defined service is deprecated since Symfony 3. 3 并且 Symfony 4.0 将不再支持

我的项目是一个带有DoctrineORM的Symfony3.3.9项目。我将codeception2.3.6与模块Doctrine2一起使用,我关注这篇文章:http://codeception.com/docs/modules/Doctrine2我的codeception配置是:#tests/functional.suite.ymlactor:FunctionalTestermodules:enabled:-\Helper\Functional-PhpBrowser:url:http://localhost-Symfony-Doctrine2:depends:Symfonyclean

php - __get() 和 __set() 的最佳实践

按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter指导。关闭10年前。源于此question关于使用__get()和__set()访问私有(private)变量,我想了解一下它们的一般使用方式。我想知道何时何地是使用重载函数的最佳时机,以及您在哪里使用过重载函数(如果有的话)。为了清楚起见,我们正在谈论这些功能:http://us2.php.net/manual/en/language.oop5.magic.php

php __get() 和 __set() 魔术的要点

PHP5引入了魔术方法__get()和__set()。根据我的理解,这是必须编写每个成员的getter和setter的捷径;$var=$name;}function__get($var){return$this->$var;}}$person=newPerson();$person->firstname="Tom";$person->lastname="Brady";echo$person->firstname."".$person->lastname;//print:TomBrady?>我的问题是,这就像公开成员变量一样。classPerson{public$firstname;pu

php - Zend_Cache - "Datas must be string or set automatic_serialization = true"

我正在尝试像这样使用Zend_Cache缓存一个数组:$cache=Zend_Registry::get('cache');//$dataisanarray$cache->save($data,'externalData');我收到这个错误:Message:Datasmustbestringorsetautomatic_serialization=true即使在引导文件中初始化Zend_Cache时automatic_serialization设置为真:protectedfunction_initCache(){$frontend=array('lifetime'=>7200,'aut

php - undefined offset : 1

在我当前的PHP脚本中出现此错误:undefinedoffset:1我的代码在这里:$query="SELECTitem_id,username,item_contentFROMupdatesORDERBYupdate_timeDESCLIMIT".$start.",".$number_of_posts;$result=mysql_query($query)ordie(mysql_error());while($row=mysql_fetch_assoc($result)){preg_match("/(.*)/",$row['item_content'],$matches);$row[

php - 防止调用 error_reporting() 和/或 ini_set ('display_errors' , 'On' ) 覆盖 php.ini 设置

我的php.ini文件中有这个设置:error_reporting=E_ERROR|E_PARSE|E_CORE_ERROR|E_COMPILE_ERROR但我仍然每分钟在错误日志中收到数以千计的通知和警告条目。我当然意识到我会更好地处理这些错误,但这不是我的代码,我也不会为此付费,我只需要摆脱那些肥胖的error_log文件(每天Gbs)。我搜索了代码并删除了所有error_reporting()调用,这样就成功了,但是,有没有办法禁止error_reporting()覆盖php.ini?ini设置?我是否也可以防止对ini_set('display_errors')的调用覆盖php

当在类中定义魔术方法 __get 和 __set 时,PHP 函数 Empty 不起作用

目前我在YII框架中工作,我在其中创建了一个扩展CFormModel的类,在该类中,我覆盖了以下函数:publicfunction__get($name)publicfunction__set($name,$value)我已进行以下检查以确保end_date和start_date不为空if(!empty($this->end_date)AND!empty($this->start_date)){**/*NotWorking*/**/*SomeApplicationLogic*/}但是它不能正常工作并且条件不满足。当我调试代码时,我开始知道$this->start_date和$this-

php - 警告 : Illegal string offset 'id'

这个问题在这里已经有了答案:IllegalstringoffsetWarningPHP(17个答案)关闭9年前。我定义了两个变量如下:$pic=get_tax_meta($books->term_id,'books_field_id',true);$imageurl=wp_get_attachment_image_src($pic[id],'list-thumb');print_r($pic)结果如下:Array([id]=>302[src]=>http://localhost/mysite/wp-content/uploads/2013/10/apic.jpg)但是,我从$pic[i