Urgent help on include file problem in PHP Smarty!
帅帅的阿猪
帅帅的阿猪 2017-10-25 20:18:35
0
1
1484

捕获.JPG

The picture is my site directory, index.php is in the root directory, head.php and the instantiated smarty class file (config.php) are in the include directory, and templates store index Directory of .html and head.html files.

I would like to ask why I instantiated classes in index.php and head.php respectively, then assigned an attribute, displayed the corresponding html file, and then used {include file= in index.html 'head.html'} shows that the variable I gave in head.php does not exist? Access index.php and head.php respectively. Normal

post code:

index.php file

<?php
require_once 'include/config.php';
$sm->assign('title','hello');
$sm->display('templates/index.html');
?>

index.html file

{include file='head.html'}
{$title}
</body>
</html>

head.php File

<?php
require_once 'config.php';
$sm->assign('hea','这是head头部');
$sm->display(FILES.'templates/head.html');
?>

head.htmlFile

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
{$hea}


帅帅的阿猪
帅帅的阿猪

我是一只帅帅的阿猪

reply all(1)
路过

Have a look at the path of the imported file in head.php, is that correct?

  • reply That's right, it's normal for me to access head.php and Index.php separately.
    帅帅的阿猪 author 2017-10-26 09:36:11
  • reply Reply 0: How is it considered normal? Have you instantiated the $sm you used? That is $sm = new Smarty();
    路过 author 2017-10-26 09:42:39
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template