草庐IT

member-variables

全部标签

php - ( fatal error : Call to a member function bind_param() on a non-object)

这个问题在这里已经有了答案:Whattodowithmysqliproblems?Errorslikemysqli_fetch_array():Argument#1mustbeoftypemysqli_resultandsuch(1个回答)关闭4个月前。我收到此文本的错误:(抱歉我的英语不好,我来自德国!)错误:fatalerror:在第44行/users/ftf/www/ccache.php中的非对象上调用成员函数bind_param()部分代码来自ccache.php//NeuesDatenbank-Objekterzeugen$db=@newmysqli('localhost',

php - ReflectionException "Cannot access non-public member",但属性可访问?

我正在以这种方式更改我的反射类的可访问标志:protectedfunctiongetBaseSubscriptionPeriodReflection(){$reflection=new\ReflectionClass('Me\Project\Class');//Makeallprivateandprotectedpropertiesaccessible$this->changeAccessibility($reflection,true);return$reflection;}protectedfunctionchangeAccessibility(\ReflectionClass$r

php - 简单的 PHP 类, undefined variable ?

我正在学习PHP中的类和对象,但我真的很困惑。这是我目前所拥有的:$test1;?>每当我运行它时,我都会收到这些错误:Notice:Undefinedvariable:test1in////online9Fatalerror:Cannotaccessemptypropertyin////online9 最佳答案 对象属性不需要第二个$(除非您使用可变变量)。echo$test->test1;您使用$来引用变量,然后使用->来指定您正在查看的属性。另一方面,如果您有一个名为$var且值为test1的变量,您可以这样做:$var='t

php - 错误 : Call to a member function find() on a non-object in cakephp controller

我是cakephp的新手,并尝试使用控制台工具生成一些CRUD操作。它工作正常,除了一张table(最大的)。尝试添加新元素时,返回:Error:Calltoamemberfunctionfind()onanon-objectFile:C:\wamp\www\cakephp\app\Controller\ChantiersController.phpLine:50这是第50行及以后的代码:$programs=$this->Chantier->Program->find('list');$etats=$this->Chantier->Etat->find('list');$types=$

php - 使用对象访问 Variable 变量

我真的不知道如何描述这个问题,所以如果标题有点不清楚,我很抱歉。我得到了一个带有数组字段的对象。我将这些字段的名称存储在一个变量中,我想访问其中一个数组字段中的一个元素。例如$field_name='array_field';$object=newstdClass();$object->array_field=array('this','is','an','array);我知道我可以使用$object->$field_name访问数组,但现在我想在使用$field_name访问它的同时通过键访问数组中的值多变的。例如(这显然行不通)$object->$field_name[0]

php - 在处理可能 undefined variable 时,在 PHP 中使用引用赋值是不好的做法吗?

我一直在考虑使用引用赋值作为处理潜在undefinedvariable的捷径。换句话说,代替:$foo=isset($this->blah['something']['else'])?$this->blah['something']['else']:null;if(!is_null($foo)&&...){//dosomethingwith$foo}我可以这样做:$foo=&$this->blah['something']['else'];if(!is_null($foo)&&...){//dosomethingwith$foo}看起来更简单,对吧?由于PHP通过引用处理赋值的方式,我

php - 第 332 行的 fatal error : Call to a member function getId() on a non-object in C:\wamp\www\magentno\lib\Varien\Data\Tree\Dbp. php

我正在使用Magento1.8.0.0,我通过本地主机在WAMP服务器上安装了一个测试版本,当我想添加类别时,出现下一个错误:fatalerror:在C:\wamp\www\magentno\lib\Varien\Data\Tree\Dbp.php中的非对象上调用成员函数getId()第332行我还没有开店,因为我需要那个类别。我已经在出现错误的行中添加了tryandcatch代码。这是给出错误的代码:publicfunctionloadEnsuredNodes($category,$rootNode){$pathIds=$category->getPathIds();$rootNod

php - 如何停止此检查 : "Member has protected access, but class has magic method __get"?

如何停止检查:"Memberhasprotectedaccess,butclasshasmagicmethod__get"?我到处搜索,但找不到禁用此检查的选项。我真的不希望属性在private时仍然用不同的颜色标记,并且类中有一个神奇的方法__get。 最佳答案 正如@LazyOne提到的解决方案是:@property字符串$File在php文档中。 关于php-如何停止此检查:"Memberhasprotectedaccess,butclasshasmagicmethod__get"

php - Laravel 5 : How can I pass a variable from a controller method to app. Blade .php?

我在布局文件app.blade.php中显示了一个变量。该变量在我的全局“ViewComposer”中定义了一个默认值。我需要从Controller方法中覆盖该值,我该怎么做? 最佳答案 这是一个棘手的问题。问题是View编写器在Controller返回View后被触发。但是,如果已设置该值,您可以在View编辑器中检查:publicfunctioncompose(View$view){if(!$view->offsetExists('foo')){$view->with('foo','default');}}当您想“覆盖”Cont

php - Laravel DI : call controller method without passing injected variable, 这可能吗?

classSomeControllerextendsController{publicfunctiondoALot(Request$request){$this->doOne($someOtherVariable);//Typeerror:Argument1passedtoApp\Http\Controllers\SomeController::doOne()mustbeaninstanceofIlluminate\Http\Request$this->doOne($request,$someOtherVariable);//Badpractice?...}publicfunction