1
php?r =我的Yii演示應用程序的站點/索引...我把一個名爲hello的函數放在那裏,但它不在函數內部(hello world does not get印刷)..任何人都可以幫我在此Yii索引頁面不打印函數內的值
<?php
/* @var $this SiteController */
$this->pageTitle=Yii::app()->name;
?>
// <h1>Welcome to <i><?php echo CHtml::encode(Yii::app()->name); ?></i></h1>
<?php
function hello(){
echo 'Hello world';
}
?>
// <p>Congratulations! You have successfully created your Yii application.</p>
// <p>You may change the content of this page by modifying the following two files:</p>
// <ul>
// <li>View file: <code><?php echo __FILE__; ?></code></li>
// <li>Layout file: <code><?php echo $this->getLayoutFile('main'); ?></code></li>
// </ul>
// <p>For more details on how to further develop this application, please read
// the <a href="http://www.yiiframework.com/doc/">documentation</a>.
// Feel free to ask in the <a href="http://www.yiiframework.com/forum/">forum</a>,
// should you have any questions.</p>
您的問題與PHP函數使用的誤解有關。函數hello()只有在你調用它的時候纔會調用,而你沒有這樣做。 – crafter 2014-09-24 14:40:13