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

我试图用另一块的代码替换的一段代码。我可以用较小的字符串做,但一旦我添加了更大的字符串$ embedCode,它抛出一个“意外T_ENCAPSED_AND_WHITESPACE”错误

有帮助吗?

解决方案

应使用$反转义的\$

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

如果你的目标是使用增值经销商的名字,如果你想使用的变量的实际价值,那么问题是在这 - $> iViewer ...

其他提示

删除'围绕memberPassword接近$ _COOKIE

反正好像你正在寻找的语言结构,其内部没有解释变量 - 是的话,你必须使用不定界符 - 但普通字符串定义与有限“

$sample = 'qwe $asd zxc';

或逃生$以\如Marcx提出以下

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top