views:

65

answers:

2
$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

A: 

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

zerkms
A: 

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...

Marcx
actually the problem is in ' at the $_COOKIE not in $this->iViewer as you said
zerkms