Symfony implementation behavior and method of obtaining request parameter in template _php instance

Source: Internet
Author: User

This article illustrates the Symfony implementation behavior and the method of obtaining the request parameter in the template. Share to everyone for your reference, specific as follows:

I. Parameters obtained in the template

<?php echo $sf _request->getparameter (' name ', ' namespace ');? >
<?php echo $sf _request->getparameter (' name ');? >

Two. Get parameters in behavior

$request->getparameter (' name ');
Parameter
<?php echo $sf _params->get (' name ')?>
//with default values in the template
<?php echo $sf _params->get (' Name ', ' Default ']?>
//In the template to determine if a parameter exists
<?php if ($sf _params->has (' name ')):?>
<p>hello , <?php Echo $sf _params->get (' name ')?>!</p>
<?php else:?>
<p>Hello,JohnDoe!< /p>
<?php endif?>
//array containing all parameters
$request->getparameterholder ()->getall ()
// Full URI path
//' http://localhost/myapp_dev.php/mymodule/myaction '
geturi ()
//'/mymodule/myaction '
getpathinfo ()
//in action
$hasFoo = $this->getrequest ()->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 with the PHP program design based on Symfony framework.

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.