草庐IT

CLASS_EXISTS

全部标签

php - fatal error : Class 'ZipArchive' - not found when using PHPUnit

我重构了一些PHP代码并将其放入一系列PHPUnit类中。在其上运行PHPUnit(3.7.28)时(通过控制台)出现上述fatalerror。PHP版本为5.4.6-1ubuntu1.4(cli)。我知道Zip类正在工作并且可用,因为它在正常运行代码时(也通过控制台)工作想法/想法表示赞赏。谢谢!zip=newZipArchive();}} 最佳答案 在命名空间内,您必须使用完全限定的类名来引用类(函数除外)或首先导入它们:$this->zip=new\ZipArchive();或namespacephpUnit\Test;use

php - Bootstrap : active class

在Bootstrap中,事件类用于获取选定的单选按钮值。单击单选按钮时,active类将添加到该按钮的标签中。提交表单后,带有事件标签的单选按钮值被发送以供进一步处理。但是,当从jquery添加active类并提交表单时,它不会发布/获取该按钮的值。为了完成这项工作,我必须使用事件类模拟点击单选按钮。我做错了什么吗?还有其他方法可以实现吗?functionshowOption(){$(document).ready(function(){$('#option_grpinput[value=]').parent('label').addClass('active').click();})

php - php父类(super class)如何访问其子类的 protected 方法?

我今天才注意到这种行为-很奇怪,我很确定在java中你只能访问继承链上游的protected方法,因为另一种方式违反了封装。语言中有这种行为的原因吗? 最佳答案 我发现当在父类中定义的一个方法只需要根据扩展类类型更改其功能的一小部分时,它很有用。您可以从父类中调用抽象方法,并且它的功能会根据需要随着子类中该方法的定义而改变。我还要补充一点,兄弟类也可以访问彼此的protected属性和方法,只要它们在父类中声明(可以是抽象的也可以不是)。 关于php-php父类(superclass)如

php - Zend 框架 : Setting decorators and labels - should this be done in the view or the form class?

我注意到许多(大多数?)人在使用ZendFramework时会在Form类本身中添加装饰器和标签。classUser_Form_AddextendsZend_Form{publicfunctioninit(){parent::init();$username=newZend_Form_Element_Text('username');$username->setLabel('Username:')->setRequired(true)->addFilter('StringTrim')->addValidator('StringLength',$breakChainOnFailure=f

php - 函数 file_exists 在 php 中不起作用

我一直在尝试查找目录中是否存在file_exist。如果不是,我想使用不同的图像。但是当我使用file_exists函数时,它总是返回false。我使用的代码是while($r=mysql_fetch_row($res)){if(!file_exists('http://localhost/dropbox/lib/admin/'.$r[5])){$file='http://localhost/dropbox/lib/admin/images/noimage.gif';}else$file='http://localhost/dropbox/lib/admin/'.$r[5];}但是即使

PHP fatal error : Class 'Zend\Mvc\Application' not found

所以我一直在学习这个教程:http://framework.zend.com/manual/2.0/en/user-guide/routing-and-controllers.html我正处于应该运行phpunit的位置——我运行命令phpunitmodule/Album/src/Album/Controller/AlbumControllerTest.php我遇到了一个问题:PHPFatalerror:Class'Zend\Mvc\Application'notfoundin/home/...restofthefoldershere.../AlbumControllerTest.ph

PHP 继承 : child class overriding parent variable/property for use in constructor

我有一个(抽象的)父类应该在构造期间提供功能。子类可以覆盖构造函数中使用的属性:classParentextendsMiddlewareTest{//abstractchannelpropertiesprotected$title=NULL;protected$type=NULL;protected$resolution=NULL;function__construct(){parent::__construct();$this->uuid=$this->createChannel($this->title,$this->type,$this->resolution);}}classC

PHP 5.5 : accessing a static class member of a dynamic class stored in an object

我们假设如下:classa{publicstatic$foo='bar';}classb{public$classname='a';}$b=newb();是否可以通过某种方式(大括号等)直接访问$foo而不会生成“意外的::(T_PAAMAYIM_NEKUDOTAYIM)”:$b->classname::$foo//shouldresultin"bar"notinan"unexpected::(T_PAAMAYIM_NEKUDOTAYIM)"我知道并使用以下解决方法:$c=$b->classname;$c::$foo;但我想知道是否存在另一种直接访问$foo的好方法。

PHP file_exists 返回 false 但文件确实存在

我见过几个类似的问题,但没有答案适用于我的情况,除了它可能与权限有关。Apache提供的PHP脚本告诉我无法打开数据库文件。当我打印该文件的路径时,它返回一个有效路径,比如DBPATH。该文件确实存在于该位置;我给了它和它的父文件夹777权限;我给了他们user:user访问权限,其中user是所有脚本文件所属的sudoer。我对整个htdocs/文件夹做了同样的操作,以防万一。当我打印file_exists(DBPATH)时,它返回false。很可能是权限问题,但我不知道应该更改什么以使PHP具有访问权限。我也试过apache:apache。我不能suapache(用户不可用)。我的

php - Laravel 解析错误 : syntax error, unexpected T_CLASS, expecting T_STRING

我在今年8月开发了一个laravel应用程序,当时它运行良好。我现在正在尝试运行该应用程序,但它返回了这个错误:parseerror:syntaxerror,unexpectedT_CLASS,expectingT_STRINGorT_VARIABLEor'{'or'$'inD:\bkonme\artisanline31第31行是这样的:$kernel=$app->make(Illuminate\Contracts\Console\Kernel::class);我的PHP版本是5.6.14,我在windows平台上使用XAMPP。我有一些想法,因为laravel和PHP之间存在一些版本