菜鸟又来麻烦各位了

2020-05-25 19:09:42 +08:00
 sy5587

我 tpl 文件里用了一个 smarty3.1 的{html_options options=$AllLevel}为什么会报错啊, 错误代码:

Warning: require(C:\wamp64\www\php8/public/Smarty_Internal_Compile_Html_Options.class.php): failed to open stream: No such file or directory in C:\wamp64\www\php8\configs\run.inc.php on line 24

Fatal error: require(): Failed opening required 'C:\wamp64\www\php8/public/Smarty_Internal_Compile_Html_Options.class.php' (include_path='.;C:\php\pear') in C:\wamp64\www\php8\configs\run.inc.php on line 24

要改 php.ini 里的 include_path 吗要怎么改啊

4673 次点击
所在节点    PHP
29 条回复
Carlgao
2020-05-25 22:52:41 +08:00
smarty? 好久没听到过这个了,已经是上古模板引擎了吧!
sy5587
2020-05-26 09:09:13 +08:00
@Carlgao 新手啊网上找的视频有这个就学了
lifeintools
2020-05-26 09:23:31 +08:00
写成绝对路径。同时看下该路径下的文件夹 以及文件的权限
sy5587
2020-05-26 09:31:27 +08:00
@lifeintools 我换了个低版本的 smarty 没事了,高版本单独引入 Smart 类也没事,但是我是在 public 文件夹下用一个 TPL 类 return new Smarty(),然后用 spl_autoload_register()加载 TPL 的方式载入就出现这个错误了
sy5587
2020-05-26 09:33:06 +08:00
我换了个低版本的 smarty 没事了,高版本单独引入 Smart 类也没事,但是我是在 public 文件夹下用一个 TPL 类 return new Smarty(),然后用 spl_autoload_register()加载 TPL 的方式载入就出现这个错误了
sy5587
2020-05-26 09:37:00 +08:00
我现在只能先用着低版本的了,有明白的大佬指点下我,感激不尽
xnode
2020-05-26 09:39:52 +08:00
php 高版本 有一些函数废弃了 造成 Smarty 不能用
建议用 php5.6
sy5587
2020-05-26 09:45:17 +08:00
@xnode 我的版本就是 5.6.25 啊
ChoateYao
2020-05-26 10:13:29 +08:00
现在不用 smarty 了,而且前后端分离是大趋势,PHP 本身就是最好的模板引擎。

建议学个现代点的框架,先从 Yii2 开始吧,Laravel 太花里胡哨了对待新人不好。
sy5587
2020-05-26 10:20:52 +08:00
@ChoateYao 谢谢你我先记下了,我看的是李炎恢的 PHP 第三季视频,好像是几年前的了,网上也没找到新的,我先把这个视频过一遍吧
ben1024
2020-05-26 10:37:12 +08:00
新手的话,检测下目录是否有对应文件,如果没有文件手动放一个文件
to2false
2020-05-26 10:54:56 +08:00
@ChoateYao #9 啥花里胡哨的,我看 yii 也没怎么适合入门
Canon1014
2020-05-26 12:23:41 +08:00
楼上的不要争了作为外人看 react 和 vue 争都觉得心痛,Yii 和 Laravel 还有很多人看不上但是还是很多人用的 TP 都学的挺好的反正也快,具体主攻哪个不还是看公司要求
acrazing
2020-05-26 17:04:23 +08:00
PHP 本身就是一个很完备的模板语言, 没必要用 smarty 这种花里胡哨的东西, smarty 自己搞了一堆语法, 你事实上在学习另一门语言.
sy5587
2020-05-26 17:08:11 +08:00
@acrazing 我现在照搬也搬不过去啊
acrazing
2020-05-26 17:12:14 +08:00
@sy5587 我看你说在学习, 我的意思是你没必要学 smarty, 这是个累赘
leoleoasd
2020-05-26 17:15:14 +08:00
你说用 spl_autoload_register 加载, 看上去是没用 composer 等包管理器. 还是建议先学 laravel. 现在生产没人用 smarty 了.

并且 laravel 的 blade 的语法也比 smarty 的好很多.

引用文件的时候, 用基于 __DIR__ 的相对路径引用. __DIR__是代码所在文件夹.
sy5587
2020-05-26 17:15:35 +08:00
高版本的 smarty 有问题,低版本的问题更多,折腾一下午,好像是我 run.inc.php 里的自动加载类和 smarty 有冲突
spl_autoload_register("_efc");
function _efc($_className) {
if (substr($_className, -6) == 'Action') {
require ROOT_PATH.'/controller/'.$_className.'.class.php';
} elseif (substr($_className, -5) == 'Model') {
require ROOT_PATH.'/model/'.$_className.'.class.php';
} elseif (substr($_className, -5) == 'Check') {
require ROOT_PATH.'/check/'.$_className.'.class.php';
} else {

require ROOT_PATH.'/public/'.$_className.'.class.php';
}
}

22 0.2376 3951688 class_exists ( ) ...\smarty_internal_templatecompilerbase.php:785
23 0.2377 3951992 spl_autoload_call ( ) ...\smarty_internal_templatecompilerbase.php:785
24 0.2385 3952048 _efc( ) ...\smarty_internal_templatecompilerbase.php:785

Fatal error: require(): Failed opening required 'C:\wamp64\www\php8/public/Smarty_Internal_Compile_Html_Options.class.php' (include_path='.;C:\php\pear') in C:\wamp64\www\php8\configs\run.inc.php on line 27

但是我不知道怎么改
leoleoasd
2020-05-26 17:15:51 +08:00
laravel 可以看这个文档 https://learnku.com/docs/laravel/7.x
同网站也有 laravel 的教程, 不过不知道质量如何.
nocrush
2020-05-26 17:18:31 +08:00
找个好点的视频吧,然后你这些代码看起来是上古时期的代码

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/675370

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX