Smarty problems-variables cannot be displayed in html

Source: Internet
Author: User
Question about smarty --- variable cannot be displayed in html 1.php& lt ;? Php & nbsp; include_once ("libs/Smarty. class. php "); $ smarty = new & nbsp; Smarty () smarty problem --- variables cannot be displayed in html
1. php
Include_once ("libs/Smarty. class. php ");
$ Smarty = new Smarty ();

$ Smarty-> template_dir = "templates ";
$ Smarty-> compile_dir = "compile ";
$ Smarty-> config_dir = "config ";
$ Smarty-> cache_dir = "cache ";

$ Smarty-> left_delimiter = "{";
$ Smarty-> right_delimiter = "}";
?>

2. php
Include ("smarty_include.php ");
$ Name = "this is an apple! ";
$ Smarty-> assign ("abc", $ name );
$ Smarty-> display ("index.html ");
?>

Index.html


{$ Abc}





$ Abc in index cannot display the value of $ name
2. php shows that this is an apple!
Why is this shared by Smarty HTML: templa... 'data-pics = ''>
------ Solution --------------------
Download the latest Smarty: http://smarty.php.net/
Latest version: 2.6.18
Decompress the package and rename the libs directory in the directory to smarty. copy the libs directory to your website directory, and create the templates and templates_c directories under the website root directory.
Create test. php with the following content:
Include_once ('./Smarty. class. php'); $ smarty = new Smarty ();
$ Smarty-> template_dir = "./templates"; // template storage directory
$ Smarty-> compile_dir = "./templates_c"; // compile the Directory
$ Smarty-> left_delimiter = "{"; // left delimiter
$ Smarty-> right_delimiter = "}"; // right delimiter
$ Smarty-> assign ('test', 'OK ');
$ Smarty-> display('test.html ');
?>
Grant templates_c permissions to 755

Create test.html in the templatesdirectory:
 
 
 
 
{{$ Test }}
 
 
Open test. php. if OK is displayed, your smarty is successfully installed!

------ Solution --------------------
Make sure that the smarty has been correctly configured... I don't know what version your smarty is.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.