Stripping slashes in Zend Framework.

By default Zend Framework will escape data passed to the insert() method, For example if you have a textarea in your form that is accepting input from the user, and someone writes something like I’m testing this form, this will be inserted to the database as I\’m testing this form. We have a built-in function in PHP called stripslashes() that will strip the slashes from the record, but how about if you’re populating the form fields using the $form->populate() ? the best solution is use the setEscape() inside the controller’s init() method. Let’s try it,

public function init() {
    $this->view->setEscape('stripslashes');
}

This will strip all the slashes from the view.

One Response to “Stripping slashes in Zend Framework.”

  1. Mohammed Says:

    Thank you Mubarak

Leave a Reply