慕容708150
2023-04-14 15:15:42
運(yùn)行以下代碼時(shí)出現(xiàn)控制臺(tái)錯(cuò)誤:<?php$str = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.";$str = wordwrap($str,30,'\n');?>document.write('test' + '\n');document.write( '<?php echo $str;?>' + '\n' );</script>控制臺(tái)錯(cuò)誤:Uncaught SyntaxError: missing ) after argument list。哪里有問(wèn)題?
1 回答

肥皂起泡泡
TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超6個(gè)贊
正如@u_mulder 指出的那樣,您必須將引號(hào)轉(zhuǎn)義'為:
<?php
? ? $str = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.";
? ? $str = str_replace("'", "\'", wordwrap($str,30,'\n'));
?>
<script>
? ? document.write('test' + '\n');
? ? document.write( '<?php echo $str;?>' + '\n' );
</script>
添加回答
舉報(bào)
0/150
提交
取消