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.