$replace using a custom template

Not really sure if OK to ask here, since this question isn’t exactly related to this website.

In short, I’m lost why one code is, and an almost similar code isn’t working.

Working:
[php]$search = addslashes(‘‘);
$replace = addslashes(‘ test’);

$vbulletin->templatecache = str_replace($search, $replace.$search, $vbulletin->templatecache);[/php]
Not working:
[php]$search = addslashes(‘‘);
$replace = $vbulletin->templatecache;

$vbulletin->templatecache = str_replace($search, $replace.$search, $vbulletin->templatecache);[/php]
Working:
[php]$search = addslashes(‘