php?r =我的Yii演示应用程序的网站/索引...我已经把一个名为hello的函数放在那里,但它没有进入那个函数(你好世界没有打印)..有谁可以帮我这个
<?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>
答案 0 :(得分:0)
您只声明了该功能。您需要调用该函数来执行它。
function hello(){
echo 'Hello world';
}
hello();
虽然在视图中声明一个函数是非常糟糕的风格。我认为在使用框架之前,你应该多学习一些编程知识。