Home > Backend Development > PHP Tutorial > smarty - What is the error in this php? I didn't find the mistake

smarty - What is the error in this php? I didn't find the mistake

WBOY
Release: 2016-09-05 08:59:57
Original
1556 people have browsed it

This is a snippet of code for smarty settings found online.

It prompts at the beginning
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in F:phpstudyWWWsmartysconfig.php on line 2
I saw that the second line was fine, so I typed it again, and it was the same.

Then it prompts
Parse error: syntax error, unexpected T_VARIABLE in F:phpstudyWWWsmartysconfig.php on line 4
This is very confusing, $tpl = new Smarty(); Is this sentence wrong?

Thank you.

<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 = @#<{@#;  
  $tpl->right_delimiter = @#}>@#;  
  ?></code>
Copy after login
Copy after login

Reply content:

This is a snippet of code for smarty settings found online.

It prompts at the beginning
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in F:phpstudyWWWsmartysconfig.php on line 2
I saw that the second line was fine, so I typed it again, and it was the same.

Then it prompts
Parse error: syntax error, unexpected T_VARIABLE in F:phpstudyWWWsmartysconfig.php on line 4
This is very confusing, $tpl = new Smarty(); Is this sentence wrong?

Thank you.

<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 = @#<{@#;  
  $tpl->right_delimiter = @#}>@#;  
  ?></code>
Copy after login
Copy after login

Make sure the reference path is correct, or try removing the smarty brackets. For example

<code>$tpl = new Smarty;</code>
Copy after login

The path introduced in the first line is wrong?

Like a path problem? Try removing the slash at the beginning of the path. .
The first error is probably a BOM problem, don’t use Notepad to save it.

@#What is it? Is there something wrong with my display?
In addition, many people say that it is a problem with the introduction path. Obviously this is wrong. The error occurs during the code interpretation period and has not yet been executed.

@#What the hell is this? Looking at the error message, it is not an error in new Smarty;, nor is it an error in include.

Did you copy the code online? I guess the Chinese characters caused the parsing error, which cannot be seen with the naked eye

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template