Created
June 27, 2012 07:17
-
-
Save marcusramberg/3002192 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$req->param | |
Returns GET and POST parameters with a CGI.pm-compatible param method. | |
This is an alternative method for accessing parameters in | |
$c->req->parameters. | |
$value = $c->request->param( 'foo' ); | |
@values = $c->request->param( 'foo' ); | |
@params = $c->request->param; | |
Like CGI, and unlike earlier versions of Catalyst, passing multiple | |
arguments to this method, like this: | |
$c->request->param( 'foo', 'bar', 'gorch', 'quxx' ); | |
will set the parameter "foo" to the multiple values "bar", "gorch" and | |
"quxx". Previously this would have added "bar" as another value to | |
"foo" (creating it if it didn't exist before), and "quxx" as another | |
value for "gorch". | |
NOTE this is considered a legacy interface and care should be taken | |
when using it. "scalar $c->req->param( 'foo' )" will return only the | |
first "foo" param even if multiple are present; "$c->req->param( 'foo' | |
)" will return a list of as many are present, which can have unexpected | |
consequences when writing code of the form: | |
$foo->bar( | |
a => 'b', | |
baz => $c->req->param( 'baz' ), | |
); | |
If multiple "baz" parameters are provided this code might corrupt data | |
or cause a hash initialization error. For a more straightforward | |
interface see "$c->req->parameters". |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment