草庐IT

this_needs_servo

全部标签

php - CodeIgniter $this->load->vars() 函数

我想知道$this->load->vars()在CodeIgniter中是如何工作的。文档对此相当模糊。我有以下代码:$init=$this->init->set();$this->load->view('include/header',$init);$this->load->view('include/nav');$dates=$this->planner_model->create_date_list();$this->load->view('planner/dates_content',$dates);$detail=$this->planner_model->create_de

php - $this->"variable value"OOP PHP

我想知道这是否可能,如果可能,我应该如何实现:$this->id$this->(并在这里更改值)例如:我可能有$this->id$this->allID$this->proj_id我怎样才能使我实际上拥有$this->(此处为$myvariable,其中有一个唯一的名称)? 最佳答案 你可以简单地使用这个:$variable='id';if(isset($this->{$variable})){echo$this->{$variable};} 关于php-$this->"variable

php - Facebook 通知 API : "This method must be called with an app access_token"

我正在尝试使用GraphAPIExplorer从我的应用程序发送Facebook通知。所以我选择了我的应用程序,POST,并在/之后输入了这个字符串11093774316/notifications?access_token=430xxxxxx156|HU0ygMtxxxxxxxxxxxxikVKg&template=Hello&href=index.php访问字符串是我在“访问token调试器”上得到的,我检查它是否正常。但是,我收到此错误消息:{"error":{"message":"(#15)Thismethodmustbecalledwithanappaccess_token.

php - 有没有办法重新分配 $this?

首先,我不想扩展一个类。理想情况下,我想这样做。publicfunction__construct(){/*SetFrameworkVariable*/global$Five;$this=&$Five;}我有一个系统,其中变量$Five是一个包含其他库的容器类。我可以将其分配给Five的局部变量...即publicfunction__construct(){/*SetFrameworkVariable*/global$Five;$this->Five=$Five;}但是,我试图避免这种情况的原因是函数调用会变得有点长。$this->Five->load->library('librar

php - 类上下文中的 call_user_func(定义了 $this)

有没有一种方法可以在对象的上下文中执行PHP5.3中的闭包?classTest{public$name='John';functiongreet(){eval('echo"Hello,".$this->name;');call_user_func(function(){echo"Goodbye,".$this->name;});}}$c=newTest;$c->greet();eval()可以正常工作,但是call_user_func将无法访问$this。(不在对象上下文中时使用$this)。我现在将“$this”作为参数传递给闭包,但这并不是我所需要的。

php - CodeIgniter 中的 $this->load->view() 是什么

$this用于当前类,view是方法,load是什么。这是属性(property)吗?这个例子是否正确?classsuper{public$property;publicfunctionsuperf1(){echo"hello";}publicfunctioncol(){$this->superf1();}$this->property->super1();} 最佳答案 是的,load是一个属性。可以这样想:classLoader{publicfunctionview(){//code...}}classMyClass{privat

php - PHP 中 $this->a 和 $this->$b 的区别

有什么区别:$this->$a和$this->b在我的课上我有这个:classsomeClass{public$a;functionaFunction(){$this->a=5;$this->$b=7;}}在$this->$b中有额外的'$'有什么作用? 最佳答案 区别很大:$this->a指的是你的类的属性$a$this->$b在另一方面通过存储在变量$b中的字符串名称引用属性:$b="a";$this->$bequals$this->a$b="hello"$this->$bequals$this->hello

php - 如何删除 php 中的单行注释(例如 "//remove this comment")?

我想使用正则表达式从我的代码中删除所有单行注释(例如//comments)。到目前为止,我正在使用:preg_replace('/\/\/(.*)/','',$html);但它也会删除像http这样的字符串://example.com. 最佳答案 也许更好的方法是使用PHP引擎本身,也许使用token_get_all().该函数会将PHP脚本标记化,因此您可以完全按照PHP查看它的方式查看它,从而删除或替换注释。单独使用正则表达式执行此操作充其量只是一场噩梦,而且很可能根本不可能。 关于

PHP - 如何解决错误 "using $this when not in object context"?

我有这个特质类:traitExample{protected$var;privatestaticfunctionprintSomething(){print$var;}privatestaticfunctiondoSomething(){//dosomethingwith$var}}这个类:classNormalClass{useExample;publicfunctionotherFunction(){$this->setVar($string);}publicfunctionsetVar($string){$this->var=$string;}}但是我收到了这个错误:fatale

php - 如何在 PHP5 : $this->foo->bar->baz() 中链接对象

如何在PHP5类中创建链接对象?示例:$myclass->foo->bar->baz();$this->foo->bar->baz();Not:$myclass->foo()->bar()->baz();另请参阅:http://www.talkphp.com/advanced-php-programming/1163-php5-method-chaining.html 最佳答案 实际上这个问题是模棱两可的......对我来说这个@Geo的回答是正确的。你(@Anti)说的可能是composition这是我的例子:what=$what