我使用Hive Logic Enkoder生成了模糊處理的電子郵件。我想在PHP中回顯結果。在PHP中完全字符串輸入
問題是它包含'
,"
,\\
和\\\\
,所有這些都弄亂了PHP如何讀取字符串。我怎樣才能讓PHP從字面上理解 - 逃避需要逃跑的角色,並且不逃避那些不需要的角色?
所以我想:
echo '<script type="text/javascript">
//<![CDATA[
<!--
var x="function f(x){var i,o=\"\",ol=x.length,l=ol;while(x.charCodeAt(l/13)!" +
"=102){try{x+=x;l+=l;}catch(e){}}for(i=l-1;i>=0;i--){o+=x.charAt(i);}return " +
"o.substr(0,ol);}f(\")12,\\\",&.=1,p?3k`,gcheB8'Xfo!l720\\\\430\\\\120\\\\>X" +
"%E220\\\\230\\\\100\\\\530\\\\700\\\\RS,OT130\\\\630\\\\400\\\\230\\\\130\\" +
"\\530\\\\4[120\\\\700\\\\600\\\\010\\\\300\\\\520\\\\,a038t=68&>&2?120\\\\(" +
"*\\\"\\\\,v$>%!&+g030\\\\~$$2Wt\\\\I330\\\\400\\\\r\\\\JOGUImi3hu771\\\\tmt" +
"yq\\\"(f};o nruter};))++y(^)i(tAedoCrahc.x(edoCrahCmorf.gnirtS=+o;721=%y;i=" +
"+y)12==i(fi{)++i;l<i;0=i(rof;htgnel.x=l,\\\"\\\"=o,i rav{)y,x(f noitcnuf\")" ;
while(x=eval(x));
//-->
//]]>
</script>
';
編輯:這裏是我現在使用的功能:
function supportEmail() {
$str = <<<'EOT'
<script type="text/javascript">
//<![CDATA[
<!--
var x="function f(x){var i,o=\"\",ol=x.length,l=ol;while(x.charCodeAt(l/13)!" +
"=102){try{x+=x;l+=l;}catch(e){}}for(i=l-1;i>=0;i--){o+=x.charAt(i);}return " +
"o.substr(0,ol);}f(\")12,\\\",&.=1,p?3k`,gcheB8'Xfo!l720\\\\430\\\\120\\\\>X" +
"%E220\\\\230\\\\100\\\\530\\\\700\\\\RS,OT130\\\\630\\\\400\\\\230\\\\130\\" +
"\\530\\\\4[120\\\\700\\\\600\\\\010\\\\300\\\\520\\\\,a038t=68&>&2?120\\\\(" +
"*\\\"\\\\,v$>%!&+g030\\\\~$$2Wt\\\\I330\\\\400\\\\r\\\\JOGUImi3hu771\\\\tmt" +
"yq\\\"(f};o nruter};))++y(^)i(tAedoCrahc.x(edoCrahCmorf.gnirtS=+o;721=%y;i=" +
"+y)12==i(fi{)++i;l<i;0=i(rof;htgnel.x=l,\\\"\\\"=o,i rav{)y,x(f noitcnuf\")" ;
while(x=eval(x));
//-->
//]]>
</script>
EOT;
echo $str;
}
但我得到這個錯誤返回:
解析錯誤:語法錯誤,意外的$結束,期待T_VARIABLE或T_END_HEREDOC或T_DOLLAR_OPEN_CURLY_BRACES或T_CURLY_OPEN
顯示如何閱讀此字符串。除非您以某種方式運行該文本,否則PHP不會對嵌入在字符串中的元字符執行任何操作,例如通過eval()。 – 2012-07-31 14:16:23
聽起來像你想要的是[nowdocs](http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc)。 – Palladium 2012-07-31 14:18:46
語法錯誤是因爲您的結尾'EOT;'*必須*在其行的開頭(即:之前沒有空格,並且沒有任何空格)。 – Palladium 2012-07-31 14:42:12