草庐IT

constructible

全部标签

PHP Mongo:注意:Mongo::__construct(): 解析服务器

我想知道为什么我会收到以下php通知:(!)Notice:Mongo::__construct():parsingserversinC:\htdocs\multishop\library\Lupi\Resource\Odm.phponline38CallStack#TimeMemoryFunctionLocation10.0004138504{main}()..\index.php:020.0130667392Zend_Application->bootstrap()..\index.php:2530.0130667488Zend_Application_Bootstrap_Boots

php - self::__construct() 和 new self() 之间的确切区别

你能告诉我returnself::__construct()和returnnewself()之间的确切区别吗?看起来实际上可以在创建对象时从__construct()调用返回一个self::__construct(),返回对象本身就像第一个__construct()从未被调用过。 最佳答案 这在代码中得到了最好的说明:classMyClass{public$arg;publicfunction__construct($arg=NULL){if($arg!==NULL)$this->arg=$arg;return$this->arg;

php - 在其他方法中使用来自 __construct() 的变量

我在__construct()中定义了一个新变量,我想在这个class的另一个function中使用它。但是我的变量在另一个函数中是空的!这是我的代码:classtestObject{function__construct(){global$c;$data=array("name"=>$c['name'],"family"=>$c['family']);}functionshowInfo(){global$data;print_r($data);}} 最佳答案 在构造函数中将变量$data声明为全局变量:function__cons

PHP/CodeIgniter - 在 __construct() 中设置变量,但它们不能从其他函数访问

我很高兴遇到一个变量范围问题。也许我只是需要更多的咖啡...这是我的(简化的)代码-这是在CodeIgniter2中:classAgentextendsCI_Controller{publicfunction__construct(){parent::__construct();$this->load->model('agent_model');//Getpreliminarydatathatwillbeoften-usedinAgentfunctions$user=$this->my_auth_library->get_user();$agent=$this->agent_model

php - 我必须在构造函数的第一行调用 parent::__construct() 吗?

我知道在Java中,构造函数中的super()必须作为重写构造函数的第一行调用。这是否也适用于PHP中的parent::__construct()调用?我发现自己写了一个这样的异常类:classMyExceptionextendsException{publicfunction__construct($some_data){$message='';$message.=format_data($some_data);$message.='waspassedbutwasnotexpected';parent::__construct($message);}}我想知道这是否会被视为PHP中的

PHPStorm 对 __construct() 的@return void 发出尖叫

我正在使用PHPStorm并试图找出当__construct()在其PHPDocs中有@returnvoid时如何让它停止尖叫...根据PHPDocs,void是有效的,或者可以省略@return。话虽这么说,有没有办法解决这个问题或者这是一个错误? 最佳答案 不幸的是,您不能只关闭这个非常具体的检查。需要关闭整个PHPDoc方法签名检查。幸运的是你可以setthescopeoftheinspection仅作为您自己的项目代码,忽略第3方库和框架。请参阅说明下方右侧的范围下拉列表。您还可以根据具体情况关闭每个PHPDoc注释上方的检

php - laravel 5.4:无法在 __construct 方法中访问 Auth::user()

在以前版本的Laravel中,在我需要访问已登录用户的所有方法中的Controller中,我曾经做过这样的事情:classDashboardControllerextendsController{private$user;function__construct(Request$request){$this->middleware('auth');$this->user=\Auth::user();}functionfunc_1(){$objects=Objects::where('user_id',$this->user->id)->get();}functionfunc_2(){$o

php - 可捕获的 fatal error :传递给 UsernamePasswordToken::__construct() 的参数 4 必须是数组,给定为空

登录我的Symfony应用程序时出现以下错误(使用正确的用户名和密码):ContextErrorException:CatchableFatalError:Argument4passedtoSymfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken::__construct()mustbeanarray,nullgiven,calledinD:\xampp\htdocs\essweb\vendor\symfony\symfony\src\Symfony\Component\Security\Cor

php - fatal error :未捕获异常 'Exception',消息为“DateTime::__construct(): 无法解析时间字符串

我收到这个错误(!)Fatalerror:Uncaughtexception'Exception'withmessage'DateTime::__construct():Failedtoparsetimestring(06-28-201407:43:58)atposition0(0):Unexpectedcharacter'in/Users/matt/Desktop/Likes/forgot/activate.phponline17尝试这样做时//DBquery$stmt=$con->prepare("SELECTtoken_created_atfromresetWHEREtoken=

c++ - allocator.construct 循环是否等于 std::uninitialized_copy?

在此背景下T是某种类型并且allocator是该类型的分配器对象。默认情况下为std::allocator但这不一定是真的。我有一大块内存被allocator.allocate(n)获取了.我还有一个容器con的T对象(比如std::vector)。我想用T初始化那block内存对象。内存块的位置存储在T*data中。.这两个代码示例是否始终相同?#include//example1std::uninitialized_copy(con.begin(),con.end(),data)//example2std::vector::const_iteratorin=con.begin();