joomla 1.6:$ app对象如何打印出整个页面内容

Joh*_*n K 1 php joomla joomla1.5 joomla-extensions joomla1.6

我正在检查joomla 1.6 index.php,我在最后一行找到了以下代码

echo $ app;

这将打印整个页面内容.

我刚刚使用print_r()打印出该对象中的内容,我得到了以下详细信息

JSite Object
(
    [template:JSite:private] => stdClass Object
        (
            [id] => 6
            [home] => 1
            [template] => beez5
            [params] => JRegistry Object
                (
                    [data:protected] => stdClass Object
                        (
                            [wrapperSmall] => 53
                            [wrapperLarge] => 72
                            [logo] => images/sampledata/fruitshop/fruits.gif
                            [sitetitle] => Matuna Market 
                            [sitedescription] => Fruit Shop Sample Site
                            [navposition] => left
                            [html5] => 0
                        )

                )

        )

    [_language_filter:JSite:private] => 
    [_detect_browser:JSite:private] => 
    [_clientId:protected] => 0
    [_messageQueue:protected] => Array
        (
        )

    [_name:protected] => site
    [scope] => 
    [requestTime] => 2011-10-17 17:23
    [startTime] => 1318872200.5365
    [_errors:protected] => Array
        (
        )

)
Run Code Online (Sandbox Code Playgroud)

所以echo $ app如何显示所有网站内容,它不包含对象中的任何HTML内容.

非常感谢你

Com*_*eek 5

__toString()在类中声明了魔术方法.

如果在类中声明了此函数,则在将对象转换为字符串时将使用它的返回值.

简单的例子:http://codepad.org/UmZUQA3v