Detecting POST Requests in Zend Framework

Pure PHP

Pure phpiers are using used to something like detecting a submit in the _POST array.

if (isset($_POST['submit']) { ... }

Of course for this you’ve to be sure the HTML contains an submit type element with name attribute equal to “submit”.

The Zend Framework’s Way

Simply replace the line above with:

if ($this->getRequest()->isPost()) { ... }

This is way better than the first example. It detects the request method, not an array element!?

One thought on “Detecting POST Requests in Zend Framework

Leave a Reply

Your email address will not be published. Required fields are marked *