为什么netbeans和PHP都不报告此代码中的错误

为什么netbeans和PHP都不报告此代码中的错误,php,Php,为什么netbeans和PHP都不报告此代码中的错误: public function __construct () { global $blog; $this->_blog_id = $blog->blog_id; $this->_post_amount = $blog-> $this->_limit_per_page = $blog->config_get('posts_limit_per_page'); $this->_short_sign_lim

为什么netbeans和PHP都不报告此代码中的错误:

public function __construct ()
{
global $blog;
$this->_blog_id = $blog->blog_id;
$this->_post_amount = $blog->
$this->_limit_per_page = $blog->config_get('posts_limit_per_page');
$this->_short_sign_limit = $blog->config_get('posts_short_sign_limit');
}
我接到一个电话,忘记了那条未完成的第三条线路,保存了我的工作,网站也在上面悄无声息地消失了

$this->_post_amount = $blog->
$this->_limit_per_page = $blog->config_get('posts_limit_per_page');
也可以写成

$this->_post_amount = $blog->$this->_limit_per_page = $blog->config_get('posts_limit_per_page');
这毫无意义,但却是完全正确的

但是,在您的情况下,它会中断您的脚本,因为使用
$instance->$other\u instance
而不使用
\u toString
方法会导致此错误:
类测试的对象无法转换为字符串。IDE不检查这一点,因为它实际上是一个边缘情况,只要它不是
$this->$this
而是
$this->$this
,而
$this
是另一个函数的返回值,就几乎不可能知道
$this
可以是什么


下面是一些示例代码,它证明了
$this->$this
实际上可以很好地工作:

<?php
class Foo {
    public $foo = 'bar';
}

class Test {
    private $xyz;
    function __construct() {
        $this->xyz = new Foo();
    }
    function __toString() {
        return 'xyz';
    }
    function run() {
        echo $this->$this->foo;
    }
}

$t = new Test();
$t->run();

也可以写成

$this->_post_amount = $blog->$this->_limit_per_page = $blog->config_get('posts_limit_per_page');
这毫无意义,但却是完全正确的

但是,在您的情况下,它会中断您的脚本,因为使用
$instance->$other\u instance
而不使用
\u toString
方法会导致此错误:
类测试的对象无法转换为字符串。IDE不检查这一点,因为它实际上是一个边缘情况,只要它不是
$this->$this
而是
$this->$this
,而
$this
是另一个函数的返回值,就几乎不可能知道
$this
可以是什么


下面是一些示例代码,它证明了
$this->$this
实际上可以很好地工作:

<?php
class Foo {
    public $foo = 'bar';
}

class Test {
    private $xyz;
    function __construct() {
        $this->xyz = new Foo();
    }
    function __toString() {
        return 'xyz';
    }
    function run() {
        echo $this->$this->foo;
    }
}

$t = new Test();
$t->run();

这是因为你在技术上

$this->_post_amount = $blog->{$this->_limit_per_page} = $blog->config_get('posts_limit_per_page');

这是有效的。

这是因为从技术上讲,你在做

$this->_post_amount = $blog->{$this->_limit_per_page} = $blog->config_get('posts_limit_per_page');

这是有效的。

为什么要在生产中使用未经测试的代码@ThiefMaster名为Agile development.Its,位于我的私有开发服务器上,最上面是im only developer;)无论如何,谢谢你的关心:)哦,如果你的网站“悄然消亡”,你应该将你的开发服务器的PHP配置为
display\u errors=on
error\u reporting=E\u ALL
via PHP.ini我有它,我检查了日志(它会进入单独的日志,我在ssh会话中也会跟踪-f,什么都没有>,为什么要在生产中使用未经测试的代码?!@ThiefMaster它叫做Agile development.Its在我的私有开发服务器上,在它之上是im only developer;)无论如何,感谢您的关注:)哦,如果您的网站“悄然消亡”您应该通过PHP将开发服务器的PHP配置为
display_errors=on
error_reporting=E_ALL
。我有它,我检查了日志(它进入单独的日志,我在ssh会话中也跟踪-f,没有任何内容>,OK,如果它有效-为什么脚本停止在那里,而没有继续到其他部分,就像它会死一样();因为在您的情况下,
$this->$this
不会产生任何有用的结果,因此尝试访问此非对象上的属性将使您的script.okie崩溃,那么如果它是有效的-为什么脚本停止在那里而没有继续到其他部分,就像它会死掉一样();因为在您的情况下,
$this->$this
不会产生任何有用的结果,因此尝试访问此非对象上的属性将使脚本崩溃。