phpzend-frameworkzend-view

Why is this code full of slashes


I'm reading some RAW code from here http://www.zfsnippets.com/snippets/view/id/17/output/raw/table-view-helper where the author is doing a lot of slash escaping like this \'class\'.

protected $_attribs = array(
    \'class\' => \'table\',
    \'cellpadding\' => \'0\',
    \'cellspacing\' => \'0\',
    \'border\' => \'0\',
);

From what I understand it's supposed to be code that will be used to construct the markup of a table. Why exactly is the author doing it this way and isn't there a better way than this hideous workaround. I was thinking double quotes should do "'class'" but not sure. Anyone knows for sure what's the right way of doing this?

This is everywhere else where this var is called. It's basically being used after that in a getter setter style, with array_merge I guess

public function setAttribs($options = null)
{
    if (is_array($options)) {
        $this->_attribs = array_merge($this->_attribs, $options);
    }
    return $this;
}

Solution

  • I think that just the blog or site where this code belongs wrong escaped it. Just ignore them.