cakephp - 如何让 $this->webroot 在 CakePHP 3.0 中工作

标签 cakephp cakephp-3.0

我的 services.ctp 中有这段代码在 CakePHP 2.3.10 之前运行良好的文件。

href="<?php echo $this->webroot . 'intro/services/1'; ?>

我刚刚将此文件复制到 CakePHP 3.0.0 中,但它不再工作并抛出以下错误消息

Error: C:\apache2\htdocs\myprojxxxx\webroot\Helper could not be found.



这有什么不同$this->webroot在 CakePHP 3.0 中?

请帮忙!

最佳答案

你需要使用这个:

href="<?php echo $this->request->webroot . 'intro/services/1'; ?>

这将适用于 cakephp 3.0

关于cakephp - 如何让 $this->webroot 在 CakePHP 3.0 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29216856/

相关文章:

cakephp - 有交互式的 cakephp 控制台吗?

CakePHP 自定义路由分页

CakePHP - CakeDC 插件权限不起作用

php - 如何在 cakephp 3 中拥有全局参数?

php - 在 CakePHP 3.0 中将附加数据保存到联合表

php - 如何在 CakePHP 2 Travis 集成中自动加载 Composer 包

php - Cakephp 如何基于另一个虚拟字段创建虚拟字段

php - CakePHP 3 中的自定义配置文件

image - Cakephp 3.3 中的文件上传

MySQL:从连接表中获取每个最新条目