Quick variable usage instance of the Symfony template, and symfony template instance
This example describes the usage of quick variables in the Symfony template. We will share this with you for your reference. The details are as follows:
Some symfony variables can be directly used in the template. Using these shortcut variables, you can obtain some of the most common template information from the symfony object:
$ Sf_context: complete environment object (sfContext class instance)
$ Sf_request: request object (sfRequest class instance)
$ Sf_params: Request Parameter
$ Sf_user: current user session object (sfUser class instance)
Three common usage methods:
// 1. Long version <? Php echo $ sf_request-> getParameter ('Total')?> // 2. segment version <? Php echo $ sf_params-> get ('Total')?> // 3. Execute the following code echo $ request-> getParameter ('Total') in the action ')
I hope this article will help you design PHP programs based on the Symfony framework.
Articles you may be interested in:
- Session and cookie usage in Symfony2
- Summary of how Symfony2 can obtain data from the database
- Symfony2: how to obtain a url in the controller
- Symfony2 framework learning notes
- Explanation of HTTP Cache Usage in Symfony2 framework learning notes
- In-depth description of Symfony control layer
- Symfony core class overview
- How to create a project using the symfony command
- Details about how to create a project and a template setting instance in the Symfony2 framework
- Quick Start to Symfony
- High-performance PHP framework Symfony2 classic getting started tutorial
- Analysis on date usage in twig of symfony2.4