今天从csdn
http://topic.csdn.net/u/20090715/17/8b549255-0767-4b16-b9d7-8588ffcdeb2d.html?64203
下了个smarty做的,留言本的程序在运行时总是报如下的错误:
Fatal error: Smarty error: [in a.htm line 1]: syntax error: invalid attribute name: '113_01.htm/' (Smarty_Compiler.class.php, line 1550) in D:/AppServ/www/smarty/libs/Smarty.class.php on line 1092
刚开始还以为是冒号的原因,后来怎么改都不对。
后来在网上搜了下,找到了这个错误的解释。现在我来解释下这段错误的翻译,英语不是很好翻译有误在所难免。
Smarty error: [in file:xx.tpl line 1]: syntax error: invalid attribute name: 'index.tpl/' (Smarty_Compiler.class.php, line 1521)
//当你遇到这个错误时,说明你的magic_quotes_runtime设置是打开的在你的php.ini配置文件.
//smarty需要在这个值是关闭的时候才能运行
//切勿将magic_quotes_runtime打开与magic_quotes_gpc的值相混淆(言外之意就是两个设置是不一样的)smarty只需要将magic_quotes_runtime关闭就可以了
If you encounter an error like this, then you have magic_quotes_runtime
turned on in you php.ini. Smarty needs this value to be turned off to operate properly.
Don't mix magic_quotes_runtime
up with magic_quotes_gpc
.
Smarty only needs the former to be off.
//假如你无法更改php.ini在你的web配置当中,你可以用ini_set('magic_quotes_runtime', false);在程序运行时将其关闭
If you don't have access to your php.ini or to your webserver-configuration, then you can turn magic_quotes_runtime off at runtime with
[php:1:b7ea9ca818]ini_set('magic_quotes_runtime', false);[/php:1:b7ea9ca818]
//但最好是在配置文件中将其关闭。
But it's best to simply bother your system-administrator to turn it off globally.
我是通过这样来将其关闭的。
if(get_magic_quotes_runtime())
{
set_magic_quotes_runtime(0);
}
因为这个设置在有些版本的配置里面他是关闭的,就比如我在家里的那台电脑的php运行环境默认就是关闭的,所以我在smarty里使用include函数就不会报错。get_magic_quotes_runtime设置打开时为1否则为0
这条语句就是先判断下,是否打开,如果有的话就将其关闭,另外只要把ini_set('magic_quotes_runtime', false);这条语句或是用我上面的方法, 放在smarty的配置文件中就没问题了。
每次引入时自动判断了。
因为打开的作用还是有的。