Symfony template shortcut variable usage examples, symfony template examples
This article describes the shortcut variable usage examples of Symfony templates. Share it with everyone for your reference, the details are as follows:
In the template, there are some symfony variables that can be used directly. Some of the most commonly used template information can be obtained from symfony objects through these shortcut variables:
$sf_context: complete environment object (instance of sfContext class)
$sf_request: request object (instance of sfRequest class)
$sf_params: Requested parameters
$sf_user: Current user session object (instance of sfUser class)
Three common ways to use it:
//1. 长版本
<?php echo $sf_request->getParameter('total') ?>
//2. 段版本
<?php echo $sf_params->get('total') ?>
//3. 相当于在行为里执行下面的代码
echo $request->getParameter('total')
Copy after login
I hope this article will be helpful to everyone’s PHP program design based on the Symfony framework.
Articles you may be interested in:
- Symfony2 session and cookie usage summary
- Symfony2 implementation method to obtain data from the database summary
- Symfony2 implementation in Method of obtaining url in controller
- Detailed explanation of form usage in Symfony2 framework study notes
- Detailed explanation of HTTP Cache usage in Symfony2 framework study notes
- In-depth detailed explanation of Symfony control layer
- Overview of Symfony core classes
- How to use symfony commands to create projects
- Detailed examples of creating projects and template settings with the Symfony2 framework
- Ten-minute classic tutorial for getting started with Symfony
- Classic introductory tutorial for high-performance PHP framework Symfony2
- Analysis of date usage in twig of symfony2.4
http://www.bkjia.com/PHPjc/1111330.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1111330.htmlTechArticleSymfony template shortcut variable usage examples, symfony template examples This article describes the shortcut variable usage of Symfony templates. Share it with everyone for your reference, the details are as follows: In the template...