Smarty template, tpl display problems

Source: Internet
Author: User
Tags smarty template
The Smarty template and tpl show that the problem is that the Smarty template is learned at the beginning. All other configurations can be successful, but the first test program cannot be properly displayed & nbsp; index. php content: & nbsp; & lt ;? Php & nbsp; * load the configuration file * to ensure that the config file is correctly configured ..... Include. config. php; * sound Smarty template, tpl display problems
When I first started learning the Smarty template, all other configurations were successful, but the first test program could not be properly displayed.
Content in index. php ::
/* Load the configuration file */You can confirm that the configuration of the config file is correct .....
Include '../config. php ';
/* Declare an array */
$ Arr = array ('computerbook', 'name' => 'php advanced phase ', 'unit _ price' => array ('price' =>' $65.00 ', 'Unit '=> 'bene '));
/* Pass the title and array to the template */
$ Smarty-> assign ('title', 'Use Smarty to read the array ');
$ Smarty-> assign ('arr', $ arr );
/* Template page to be displayed */
$ Smarty-> display ('02/index. tpl ');
?>
Index in the tpl template file:


{% $ Title %}




Book purchase information:


{% * Obtain the first element value of the array using the index * %}
Book Category: {% $ arr [0] %}

{% * Use the key value to obtain the second array element value * %}
Book name: {%$ arr. name %}

{% * Use the key value to obtain the element value of the two-dimensional array * %}
Unit Price: {% $ arr. unit_price.price %}/{% $ arr. unit_price.unit %}



When accessed in a browser, the following output is displayed directly on the webpage:
Book purchase information:

{% * Obtain the first element value of the array using indexes * %} Book Category: {% $ arr [0] %}
{% * Use the key value to obtain the second array element value * %} book name: {% $ arr. name %}
{% * Use the key value to obtain the element value of the two-dimensional array * %} unit price: {% $ arr. unit_price.price %}/{% $ arr. unit_price.unit %}

Hope answers


------ Solution --------------------
What address did you access?
------ Solution --------------------
You can directly access the template page.
------ Solution --------------------
Are you accessing the index. php page? $ Smarty-> display ('02/index. tpl ');
Displayed template file

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.