Question

$embedCode = <<<EOF
getApplicationContent('video','player',array('id' => $iFileId, 'user' => $this->iViewer, 'password' => clear_xss($_COOKIE['memberPassword'])),true)
EOF;
$name = str_replace($embedCode,"test",$content);

I'm trying to replace a section of code with another piece of code. I can do it with smaller strings but once I added the larger strings to $embedCode, it throw an "unexpected T_ENCAPSED_AND_WHITESPACE" error

Was it helpful?

Solution

you should unescape the $ using \$

$embedCode = <<<EOF
    getApplicationContent('video','player',array('id' => \$iFileId, 'user' => \$this->iViewer, 'password' => clear_xss(\$_COOKIE['memberPassword'])),true)
EOF;

IF your objective is to use the vars name, if you want to use the real value of the variables, then the problem is in $this->iViewer...

OTHER TIPS

remove ' around the memberPassword near the $_COOKIE

anyway seems you're looking for language construction that not interprets variable inside - so then you have to use not HEREDOC syntax - but regular string definition limited with '

$sample = 'qwe $asd zxc';

or escape $ with \ as Marcx propose below

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top