The dollar sign and curly braces have special meanings when inside double-quoted strings. $
is used to put content from a variable directly into a string. {}
is used to wrap PHP variables in case their meaning is ambiguous.
For example "$hello"
would put the contents of the variable $hello
into the string, whereas "{$hell}o"
would put the contents of the variable $hell
into the string, followed by the literal letter o.
Single quotes don't have this at all (and are generally preferable when quoting more complex strings, for simplicity). So '{$hell}o'
would be a string containing the actual characters {$hell}o
.
It's a little unclear what exact strings you are trying to replace. To replace the literal {x+$v}
with {x-$v}
then use:
str_replace('{x+$v}', '{x-$v}', $this->introtext);