2009-08-30, 10:29 PM
I\'ve decided to write my own CMS software, partially to get a better grasp of PHP, and partially because none of the other free CMSs do what I want without me having to disable and delete a bunch of cruft I don\'t need. So far, it\'s going okay, but there\'s one issue that\'s driving me up the wall: I can\'t get my PHP to remove the \ from \\'. I\'ve tried many things, but so far all have failed.
This is what I do before sending the template to the requesting code (to be eval()ed like in MyBB):
Here\'s what I do to store the template:
This is the resulting output.
It\'s driving me insane because it looks like it should work, but it doesn\'t, and so is probably something stupid. Please, make the bad \ go away!
This is what I do before sending the template to the requesting code (to be eval()ed like in MyBB):
return str_replace('\\\'', '\'', $this->cache[$template]);
Here\'s what I do to store the template:
if(function_exists($this->db["escape"]))
{
$escapedString = $this->db["escape"]($string, $this->connection);
}
else
{
$escapedString = addslashes($string);
// Fix newlines
$escapedString = preg_replace("/\n/", '\\\n', $escapedString);
}
return $escapedString;
$this->db[\'escape\'] is merely the name of the db driver\'s string escape function.This is the resulting output.
It\'s driving me insane because it looks like it should work, but it doesn\'t, and so is probably something stupid. Please, make the bad \ go away!