• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

smarty – 请问这段php的错误在哪?我没找到错啊

php 搞代码 3年前 (2022-01-23) 19次浏览 已收录 0个评论
文章目录[隐藏]

这是网上找的smarty设置的段代码。

一开始提示
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in F:phpstudyWWWsmartysconfig.php on line 2
我看到第二行没问题啊,于是自己从新敲了一遍,一抹一样的,就好了。

然后提示
Parse error: syntax error, unexpected T_VARIABLE in F:phpstudyWWWsmartysconfig.php on line 4
这就很费解了,$tpl = new Smarty(); 这句话有错吗?

谢谢。

<code><?php    include "/smarty/libs/Smarty.class.php";    define(@#__SITE_ROOT@#, @#f:/phpstudy/WWW/smartys/smarty@#); // 最后没有斜线    $tpl = new Smarty();    $tpl->template_dir = __SITE_ROOT . "/templates/";    $tpl->compile_dir = __SITE_ROOT . "/templates_c/";    $tpl->config_dir = __SITE_ROOT . "/configs/";    $tpl->cache_dir = __SITE_ROOT . "/cache/";    $tpl->left_delimiter = @#right_delimiter = @#}>@#;    ?></code>

!本文来源gaodai.ma#com搞#代!码(网

搞gaodaima代码

回复内容:

这是网上找的smarty设置的段代码。

一开始提示
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in F:phpstudyWWWsmartysconfig.php on line 2
我看到第二行没问题啊,于是自己从新敲了一遍,一抹一样的,就好了。

然后提示
Parse error: syntax error, unexpected T_VARIABLE in F:phpstudyWWWsmartysconfig.php on line 4
这就很费解了,$tpl = new Smarty(); 这句话有错吗?

谢谢。

<code><?php    include "/smarty/libs/Smarty.class.php";    define(@#__SITE_ROOT@#, @#f:/phpstudy/WWW/smartys/smarty@#); // 最后没有斜线    $tpl = new Smarty();    $tpl->template_dir = __SITE_ROOT . "/templates/";    $tpl->compile_dir = __SITE_ROOT . "/templates_c/";    $tpl->config_dir = __SITE_ROOT . "/configs/";    $tpl->cache_dir = __SITE_ROOT . "/cache/";    $tpl->left_delimiter = @#right_delimiter = @#}>@#;    ?></code>

确保引用路径正确,或者把smarty括号去掉试试看。例如

<code>$tpl = new Smarty;</code>

第一行引入的路径不对?

像是路径问题?把路径最开始的斜杠去掉试试看。。
第一个报错像是BOM问题吧,别用记事本保存。

@#是什么,难道是我的显示有问题?
另外很多人说是引入路径的问题,显然这是不对的,错误出现在代码解释期,还没到执行呢。

@#是个什么鬼?看错误信息,你这不是 new Smarty; 出错,也不是include出错。

你是不是网上复制代码 我估计是中文字符导致解析错误 肉眼无法看出


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:smarty – 请问这段php的错误在哪?我没找到错啊

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址