Symfony implements the method for obtaining the request parameter in the behavior and template, symfonyrequest_PHP tutorial-php Tutorial

Source: Internet
Author: User
Symfony implements the method for obtaining the request parameter in the behavior and template, symfonyrequest. Symfony implementation behavior and method for obtaining the request parameter in the template. This document describes the Symfony implementation behavior and the method for obtaining the request parameter in the template. We will share with you how to obtain the request parameter in Symfony's implementation behavior and template.

This example describes how to obtain the request parameter in the Symfony implementation behavior and template. We will share this with you for your reference. The details are as follows:

1. obtain parameters in the template

<?php echo $sf_request->getParameter('name','namespace');?><?php echo $sf_request->getParameter('name');?>

2. get parameters in the action

$ Request-> getParameter ('name'); // Obtain parameters in the template <? Php echo $ sf_params-> get ('name')?> // Parameters with default values <? Php echo $ sf_params-> get ('name', 'default')?> // Determine whether a parameter exists in the template <? Php if ($ sf_params-> has ('name'):?>

Hello, <? Php echo $ sf_params-> get ('name')?>!

<? Php else:?>

Hello, JohnDoe!

<? Php endif;?> // Array containing all parameters $ request-> getParameterHolder ()-> getAll () // Complete URI path // 'http: // localhost/myapp_dev.php/mymodule/myaction 'geturi () // '/mymodule/myaction' getPathInfo () // $ hasFoo = $ this-> getRequest () in the action () -> hasParameter ('Foo'); $ hasFoo = $ this-> hasRequestParameter ('Foo'); // Shorter version $ foo = $ this-> getRequest () -> getParameter ('Foo'); $ foo = $ this-> getRequestParameter ('Foo'); // Shorterversion

I hope this article will help you design PHP programs based on the Symfony framework.

Articles you may be interested in:
  • A detailed explanation of the controller usage of Symfony2 learning Notes
  • Symfony2 development-Controller usage instance analysis
  • Symfony core Class Overview
  • How to create a project using the symfony command
  • Quick variable usage example of the Symfony Template
  • Details about how to create a project and a template setting instance in the Symfony2 framework
  • Symfony2 study notes plugin format analysis
  • System route details for Symfony2 study notes
  • Template usage of Symfony2 learning Notes
  • Symfony installation and configuration methods
  • In-depth description of Symfony control layer

The following example describes how to obtain the request parameter in the Symfony implementation behavior and template. Share it with you...

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.