Home  >  Article  >  Backend Development  >  Detailed explanation of the usage of Symfony template shortcut variables

Detailed explanation of the usage of Symfony template shortcut variables

*文
*文Original
2018-01-05 14:42:351395browse

This article introduces the usage of shortcut variables in Symfony templates, and analyzes three common methods of shortcut variable calls in Symfony templates in the form of simple examples. Friends in need can refer to it. I hope it will be helpful to everyone.

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 (sfRequest Instance of class)
$sf_params: Requested parameters
$sf_user: Current user session object (instance of sfUser class)

Three common usage methods:

//1. 长版本
getParameter('total') ?>
//2. 段版本
get('total') ?>
//3. 相当于在行为里执行下面的代码
echo $request->getParameter('total')

Related recommendations:

Detailed explanation of how symfony uses commands to create projects

Brief Describe the Symfony core class

The implementation method of using symfony paging

The above is the detailed content of Detailed explanation of the usage of Symfony template shortcut variables. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn