This article describes how to obtain request Parameters in Symfony implementation behaviors and templates. The example shows how Symfony obtains parameters in behavior and method, for more information about how to obtain request Parameters in the Symfony implementation behavior and template, see the example in this article. 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.