草庐IT

is_test_set

全部标签

PHP ini_set session gc_maxlifetime 不工作

我正在尝试在PHP中设置gc_maxlifetime。这是“header.php”中的代码,我在每个页面都包含了它。ini_set('session.cookie_lifetime',1);ini_set('session.gc_maxlifetime',1);session_start();我用它来测试echoini_get('session.gc_maxlifetime');它确实设置为1。但它仍然保持登录状态,即session没有被删除。可能的原因是什么? 最佳答案 为什么垃圾收集不运行?GC并不总是在每个请求上运行,默认的P

php - __get() 和 __set() 是否意味着泄漏封装?

在OO编程中,使用魔法方法__get()和__set()会不会被人看不起,这些会导致类的封装泄漏吗?例如:classUser{private$username;private$password;publicfunction__set($name,$value){$this->$name=$value;}publicfunction__get($name){return$this->$name;}}这有效地使private/protected变量public。 最佳答案 您的代码:classUser{private$username;

php - Composer 安装 : the json extension is missing

我在Linux终端中写道:curl-shttps://getcomposer.org/installer|php它说:#!/usr/bin/envphpSomesettingsonyourmachinemakeComposerunabletoworkproperly.Makesurethatyoufixtheissueslistedbelowandrunthisscriptagain:Thejsonextensionismissing.Installitorrecompilephpwithout--disable-json我这样做了:apt-getinstallphp5-json所以,

php - vTiger 网络服务 : Permission to perform the operation is denied for query

我正在使用vTigerWeb服务通过查询检索包含我的联系人的VtigerObjects数组。我正在按照此处给出的说明进行操作:https://wiki.vtiger.com/index.php/Webservices_tutorials到目前为止,我得到了一个可以用来登录的质询token,所以这是有效的。但是从我尝试通过查询获取数据的那一刻起,我收到以下错误:“查询执行操作的权限被拒绝”我是管理员,所以我应该拥有所有权限,对吗?这是我的代码,希望有人能帮助我?$username='xxxxxxxxxx';$userAccessKey='xXxXxXxXxXxXxX';//CreateH

php - symfony2 phpunit : how to get exception message when status code is not expected one

在我的symfony2应用程序中,我使用phpunit来测试每个Controller的Action响应的状态代码是否是预期的。如果不是,我如何让phpunit显示异常附带的错误消息,或者最好模拟一个探查器异常页面?这是因为我在phpunit中有一个返回500代码的操作,但它在我的浏览器中加载得很好。我的代码:/***@dataProviderurlProvider*@param$url*/publicfunctiontestPageIsSuccessful($url){$client=self::createClient(array(),array('PHP_AUTH_USER'=>'

php - 在脚本中使用 ini_set 是否被认为是不好的做法?

我正在进行代码审查,发现有2个地方ini_set('memory_limit','512M');在函数中使用。这个可以吗?不知何故,这对我来说似乎不对。这被认为是不好的做法吗?谢谢! 最佳答案 这没什么问题。考虑这样一种情况,其中memory_limit在PHP的ini文件中全局设置,并且您只想为一个特定的脚本/请求覆盖该设置以允许操作使用更多内存。在PHP脚本中调用ini_set只会在PHP执行该特定请求时生效。 关于php-在脚本中使用ini_set是否被认为是不好的做法?,我们在S

php - Symfony3 : How to set multiple connections?

我正在使用Symfony3应用程序,我想建立到不同数据库的多个连接。我一直在四处寻找,找到了关于entityManagers和数据库连接的文档。我的config.yml配置如下:配置.ymldoctrine:dbal:default_connection:defaultconnections:default:driver:pdo_mysqlhost:"%database_host%"port:"%database_port%"dbname:"%database_name%"user:"%database_user%"password:"%database_password%"chars

php - 交响乐 : Testing email sending in command

早上好。我想在我的Symfony命令中测试发送电子邮件。我的电子邮件是通过\Swift_Mailer发送的$this->mailer->send($message);我尝试使用这个:http://symfony.com/doc/current/cookbook/email/testing.html但是$this->client->getProfile()和SymfonyResponse在Symfony命令中不可用。Argument1passedtoSymfony\Component\HttpKernel\Profiler\Profiler::loadProfileFromRespons

php - 交响乐 2 : why injecting kernel into service is bad idea?

我需要在我的服务中获取当前的应用程序环境。我发现我可以从内核中获取它,但是很多人说注入(inject)内核是个坏主意。有人能解释一下为什么实际上它被认为是不好的做法吗?这不是比将整个容器注入(inject)我的服务更好的解决方案吗?my_app.my_not_so_great_service:class:AppBundle\Services\AppServicearguments:-"@kernel" 最佳答案 RichardMiller[0]的一篇文章解释了这个问题。其要点是,依赖于当前的应用程序环境是一种设计不当的架构的代码味道

PHP 手册 : Number Conversion in Is_Numeric Example 1?

我在PHP文档中遇到了这个例子:输出:'42'isnumeric'1337'isnumeric'1337'isnumeric'1337'isnumeric'1337'isnumeric'1337'isnumeric'notnumeric'isNOTnumeric'Array'isNOTnumeric'9.1'isnumeric“42”之后的五个示例的计算结果均为“1337”。我能理解为什么“1337e0”(科学计数法)会这样,但我不明白为什么其他人会这样。我找不到任何人在文档的评论中提到它,我也没有发现它在这里被问到,所以谁能解释为什么'0x539'、'02471'和'0b101001