草庐IT

exception_class

全部标签

php - 抑制 “Ambiguous class resolution” 警告

有没有办法在运行composerinstall时禁用“模棱两可的类解析”警告?我使用的包在不同文件夹中具有相同名称(和命名空间)的类。我知道thisbug,但这并不是因为这些类在供应商中实际上是两次。我对此无能为力。我也知道--no-autoloader标志当然不会抛出警告,只是因为它跳过了自动加载器生成。 最佳答案 与其从vendor目录中删除文件(应该避免),不如将具有不明确类的文件/目录添加到exclude-from-classmapcomposer.json中的部分:"autoload":{..."exclude-from-

php - 为什么我会收到 "Class ' app\models\Yii' not found"错误?

出现此错误的模型函数:publicfunctionsetPassword($password){$this->password_hash=Yii::$app->security->generatePasswordHash($password);}publicfunctiongenerateAuthKey(){$this->auth_key=Yii::$app->security->generateRandomString();} 最佳答案 添加useYii;在你的类声明之前。或者在Yii字前加一个反斜杠。$this->passwor

php - 未捕获的异常 'Exception' 消息为“DateTime::__construct():

我在输出在我的PHP文件中创建的日期时遇到问题。我一直在关注如何制作一个真正的Basic-CMS平台的教程,以帮助我了解databases和PHP的一些基础知识,一切都已经完成一切顺利,直到我尝试输出页面的创建日期。这是我得到的错误Fatalerror:Uncaughtexception'Exception'withmessage'DateTime::__construct():Itisnotsafetorelyonthesystem'stimezonesettings.Youare*required*tousethedate.timezonesettingorthedate_defa

php - 为什么 Exception 不是 Throwable 的实例?

我认为在所有编程语言中,Exception类都是Throwable接口(interface)的实例。看看下面的代码,它显示Exception不是php中Throwable的实例。try{thrownewInvalidArgumentException("errormessage");}catch(InvalidArgumentException$e){if($einstanceofException){echo'$eisexception';//thislinegetsexecuted}if($einstanceofThrowable){echo'$eisthrowable';//bu

PHP 和 FPDI/FPDF : Fatal error: Uncaught Exception: FPDF error: Incorrect output destination

我有一个PDF文件,我想用FDI/FPDF添加一个新页面Fatalerror:UncaughtException:FPDFerror:Incorrectoutputdestination:outfiles/111111.pdfinC:\wamp\www\pdf\fpdi\fpdf.phponline271(!)Exception:FPDFerror:Incorrectoutputdestination:outfiles/111111.pdfinC:\wamp\www\pdf\fpdi\fpdf.phponline271require_once('fpdi/fpdf.php');requ

php - 内存缓存和 PHP : Fatal error: Class 'Memcache' not found in

我发现了几个非常相似的问题。但是,每个都指向使用错误的php.ini文件或根本没有安装memcache,或者有memcached而不是memcache设置等,所以我相信这个问题是不同的,尽管搜索该错误会出现几个讨论。无论如何,当我尝试实例化一个新的Memcache对象时,我得到:fatalerror:在第360行的/websites/../app/app_controller.php中找不到类“Memcache”因为从命令行调试东西有时会给你错误的信息,我只是将我的调试添加到页面:这给了我:ConfigurationFile(php.ini)Path=>/etcLoadedConfig

php - PDO - FETCH_CLASS - 将结果作为参数传递给构造函数

有什么方法可以将PDO的结果作为构造函数的参数传递吗?比方说,我有以下类(class):classTest{private$value1;private$value2;function__construct($val1,$val2){$this->value1=$val1;$this->value2=$val2;}}然后,通过PDO驱动程序,我从数据库中选择一些数据,比方说:SELECTprice,quantityFROMstock$results=$query->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_PROPS_LATE,"Test");现在,PD

PHP 如何检查子类是否覆盖了父类(super class)的方法?

使用PHP,一个类如何确定一个子类是否覆盖了它的方法?给定以下两个类:classSuperclass{protectedfunctiondoFoo($data){//empty}protectedfunctiondoBar($data){//empty}}classSubclassextendsSuperclass{protectedfunctiondoFoo($data){//dosomething}}如何将一个方法添加到父类(superclass)中,以根据其哪些方法被覆盖执行不同的操作?例如:if([doFooisoverridden]){//Performanactionwit

php - 我可以只使用 _(下划线)作为类(class)名称吗?

我可以只使用_(下划线)作为类名吗?如果是,那么如何创建对象?如果不是,为什么不呢?class_{} 最佳答案 manual可能是你最好的friend。Theclassnamecanbeanyvalidlabel,provideditisnotaPHPreservedword.Avalidclassnamestartswithaletterorunderscore,followedbyanynumberofletters,numbers,orunderscores.Asaregularexpression,itwouldbeexpr

php - 严重性 : 8192 Message: Methods with the same name as their class will not be constructors in a future version of PHP;

严重性:8192消息:在未来的PHP版本中,与类同名的方法将不再是构造函数;CI_Pagination有一个已弃用的构造函数文件名:libraries/Pagination.php行号:27classCI_Pagination{var$base_url='';//Thepagewearelinkingtovar$total_rows='';//Totalnumberofitems(databaseresults)var$per_page=10;//Maxnumberofitemsyouwantshownperpagevar$num_links=2;//Numberof"digit"li