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}
Have a look at the path of the imported file in head.php, is that correct?