草庐IT

spl-autoload-call

全部标签

php - mb_convert_encoding 错误 : Call to undefined function mb_convert_encoding()

我目前正在编写一个PHP函数,但是在执行完整的脚本时出现错误:错误:Calltoundefinedfunctionmb_convert_encoding()我的功能:functioncleanData(&$str){if($str=='t')$str='TRUE';if($str=='f')$str='FALSE';if(preg_match("/^0/",$str)||preg_match("/^\+?\d{8,}$/",$str)||preg_match("/^\d{4}.\d{1,2}.\d{1,2}/",$str)){$str="'$str";}if(strstr($str,'

php - 在 SPL 自动加载器中抛出异常?

有没有办法在PHP中从SPL自动加载器抛出异常以防失败?它似乎不能在PHP5.2.11下工作。classSPLAutoLoader{publicstaticfunctionautoloadDomain($className){if(file_exists('test/'.$className.'.class.php')){require_once('test/'.$className.'.class.php');returntrue;}thrownewException('Filenotfound');}}//endclass//startspl_autoload_register(a

php - 相当于 PHP 的 call_user_func() 的 javascript

有没有人知道有没有?我想使用变量名调用一个函数。编辑:我在这里发布了一个关于我正在尝试做的事情的fiddle:http://jsfiddle.net/sAzPA/...js:(function($){$.fn.MyPlugin=function(){returnthis.each(function(){varsomefunction=function(arg1,arg2){alert(arg1);},someotherfunction=function(arg1,arg2){alert(arg2);},reallyimportantfunction=function(arg1,arg2

php - Gd 已安装,但 "Call to undefined function imagecreatefromjpeg()"

看起来我的主机支持gd,但我仍然遇到错误(PHP版本5.3.28)Fatalerror:Calltoundefinedfunctionimagecreatefromjpeg()这是我的phpinfo:gdGDSupportenabledGDVersionbundled(2.1.0compatible)GIFReadSupportenabledGIFCreateSupportenabledPNGSupportenabledlibPNGVersion1.2.44WBMPSupportenabledXBMSupportenabledDirectiveLocalValueMasterValue

PHP 静态工厂方法 : dynamically instantiate instance of the calling class

此PHP问题与thisquestion有关,但有点不同。我有一个名为create()的静态工厂方法,它实例化一个类实例。我希望该方法动态实例化调用它的(子)类的实例。因此,它实例化的类必须在运行时确定。但是我想这样做而不必在子类中重新定义静态工厂方法(这在我的示例中是完全有效的,因为子类没有要初始化的新数据成员)。这有可能吗?classFoo{private$name;publicstaticfunctioncreate($name){//HEREINSTEDOF:returnnewFoo($name);//IWANTSOMETHINGLIKE://returnnewget_class

php - fatal error : Uncaught Error: Call to a member function select() on null

我对php中的OOP有点陌生,我每次在模型中都会遇到这个问题,但我找不到导致这个问题的错误。我收到一条错误消息:fatalerror:未捕获错误:在我的model的getCategories函数中调用成员函数select()onnull(参见下面的代码)。$picName,"pic_desc"=>$pd,"pic_type"=>$pt];$img=parent::$db->saveTo("pictures")->setData($data)->execute();if($img){$imgId=parent::$db->lastInsertId();$data=["name"=>$n,

php - call_user_func_array 与 $controller->$method($params)?

我在我的代码中使用它:call_user_func_array(array($controller,$method),$this->params);但我发现下面的代码做了同样的事情:$controller->$method($this->params);这两个版本有什么区别吗?谢谢亚当·拉马丹 最佳答案 它们不一样。如果$method是showAction并且$this->params是array(2,'some-slug'),那么第一次调用将等同于:$controller->showAction(2,'some-slug');而第

php - Composer 自动加载 psr-4 未将命名空间添加到 autoload_psr4.php

我在项目中使用github中的自定义存储库,其中包含我的仪器集。该项目在/vendor目录中正确导入了包,但我无法使用任何类,因为它没有自动加载包的内容。我的包composer.json文件如下所示:{"name":"mynamespace/toolbox","description":"Asdfoobar.","keywords":["mynamespace","toolbox"],"license":"MIT","require":{"php":">=5.4"},"require-dev":{"codeception/codeception":"2.0.2","codeceptio

PHP fatal error : Call to undefined function password_verify()

我的XAMPP上有PHP5.5.6,我没有遇到错误。但是将我的网站上传到我们的测试环境后,出现了以下错误:PHPFatalError:Calltoundefinedfunctionpassword_verify()我们的测试环境/服务器有PHP5.5.9(我使用命令php-v检查了它)我还查看了PHP手册,它说在使用此功能时无需配置和安装。有什么想法可能导致此问题吗? 最佳答案 password_verify()自PHP5.5.0以来内置,很可能您的服务器没有运行最新的PHP版本。请务必通过phpinfo()仔细检查服务器上的PHP

php - 流明无法打开/../vendor/autoload.php

我开始使用Lumen在4月发布时。从5.0版开始,我已经遇到了同样的问题并找到了解决方案(seehere)。有几天我开始在Lumen(5.1)中创建一个新项目。但是,应用上面的.htaccess方法,这次问题并没有解决。这是完整的错误:Warning:require_once(path_of_the_project/../vendor/autoload.php):failedtoopenstream:Nosuchfileordirectoryinpath_of_the_project\bootstrap\app.phponline3Fatalerror:require_once():F