未找到类异常 - 在 Kohana 3.1 上制作 Helper
全新安装了 Kohana 3.1。尝试着打造自己的帮手。我在 application/classes/helpers/ 目录中创建了一个助手。我已将文件称为 javascript.php,该类称为 Helper_Javascript,并且有一个静态函数,仅返回“alert('sometext')”,这就是
class Helper_Javascript {
public static function alert($message)
{
return "alert('$message');\n";
}
}
当我尝试使用我刚刚使用的助手时,问题出在我的视图或控制器中kepp 收到类未找到异常。我尝试通过 调用它,但得到:
ErrorException [ Fatal Error ]: Class 'Helper_Javascript' not found.
请帮忙,我已尝试在 http://www.dealtaker.com/blog/2010/03/26/kohana-php-3-0-ko3-tutorial-part-7/" dealtaker.com/blog/2010/03/26/kohana-php-3-0-ko3-tutorial-part-7/ 但它不起作用。
您可以在这里查看我的观点:http://nabilboag.dyndns.org/simplysweet/
got a fresh install of Kohana 3.1. Trying to make my own helpers. I have created a helper in the application/classes/helpers/ directory. I have called the file javascript.php, the class is called Helper_Javascript and has a static function that just returns "alert('sometext')" here it is
class Helper_Javascript {
public static function alert($message)
{
return "alert('$message');\n";
}
}
The problem is in my view or controller when I try to use the helper i just kepp getting the Class not found exception. I have tried to call it via <?php echo Helper_Javascript::alert('asdf');?>
but get:
ErrorException [ Fatal Error ]: Class 'Helper_Javascript' not found.
Please help, I have tried to read the docs for this at http://www.dealtaker.com/blog/2010/03/26/kohana-php-3-0-ko3-tutorial-part-7/ but it doesnt work.
You can see my view here: http://nabilboag.dyndns.org/simplysweet/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
类名中的“_”用来表示目录结构。您将目录“helpers”重命名为“helper”:
application/classes/helper/
The "_" in the class name is used to represent the directory structure. You have the rename the directory "helpers" into "helper":
application/classes/helper/