Take the 2-minute tour ×

How do I apply stripslashes() to all form elements prior to output with Zend_Form?

I have tried:

//the filter
class lib_filters_Stripslashes implements Zend_Filter_Interface{
    public function filter($value){
    	return stripslashes($value);

//In the form
$form->setElementFilters(array(new lib_filters_Stripslashes));
share|improve this question

2 Answers 2

up vote 4 down vote accepted
array_map('stripslashes', $_POST)
share|improve this answer
What does trimming have to do with stripping slashes? –  Peter Smit Jul 6 '09 at 12:31

If you find that you need to stripslashes on all fields, most likely, your web host is configured to run with the deprecated magic-quotes setting turned on. If you are able, I would recommend that you turn it off instead.

share|improve this answer
The best suggestion yet! I also wouldn't fix some obscure issue, but instead get to the root of it. –  Till Jul 16 '09 at 0:02

Your Answer


