2009年3月17日星期二

Re: [fw-mvc] GET array sent with every request?

J DeBord schrieb:
> Thanks Sven,
>
> Looking at the action below, and accessing it from
> http://localhost/controller/your
>
> public function yourAction() {
>
> $request = $this->getRequest();
>
> echo ($request->isPost() ? 'Is Post' : 'Is Not Post') . '<br />';
> echo ($request->isGet() ? 'Is Get' : 'Is Not Get') . '<br />';
>
>
> }
>
> Output:
>
> Is Not Post
> Is Get
>
> I would expect it to echo "Is Not Get."

But that's not what you have there. You can either have a GET request,
or a POST request (besides any of the other requests that HTTP defines).

isGet() obviously does not give you the status whether or not the
request contained any query string or additional components within the
URL, but tells you what kind of HTTP request was received. And that has
to be GET at least.

See
http://framework.zend.com/manual/en/zend.controller.request.html#zend.controller.request.http.method

I think your misconception of what $_GET really is comes from the name
$_GET. This variable really should be named $_QUERY, because it does not
only exists with GET requests, but can exists with POST requests as
well. Just try <form action="target.php?test=get" method="post"> and
have a look at $_GET. :)

Regards,
Sven

没有评论: