smarty在模板中使用保留变量报错。
在模板上使用$smarty.get.name报错,使用$smarty.const.name也报错
相关代码
1.demo.php
<?php
require './Smarty/Smarty.class.php';
$smarty = new Smarty();
define('age','22');
$smarty->display('1-demo.html');
1.demo.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
{$smarty.get.name}
{$smarty.const.age}
</body>
</html>
游览器:localhost/smarty03/1-demo.php?name=tom
PHP报错:
Notice: Undefined index: smarty in /Users/macbook/Documents/PHP-student/smarty03/templates_c/e0e1c95d98e68dc7c3d00c8feb2a0e652ad89221_0.file.1-demo.html.php on line 31
Notice: Trying to get property 'value' of non-object in /Users/macbook/Documents/PHP-student/smarty03/templates_c/e0e1c95d98e68dc7c3d00c8feb2a0e652ad89221_0.file.1-demo.html.php on line 31
Notice: Undefined index: smarty in /Users/macbook/Documents/PHP-student/smarty03/templates_c/e0e1c95d98e68dc7c3d00c8feb2a0e652ad89221_0.file.1-demo.html.php on line 33
Notice: Trying to get property 'value' of non-object in /Users/macbook/Documents/PHP-student/smarty03/templates_c/e0e1c95d98e68dc7c3d00c8feb2a0e652ad89221_0.file.1-demo.html.php on line 33
原来是自己下载的文件有问题,重新在官网下最新版解决了