亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

PHP wordwrap 數組到 Javascript 返回錯誤

PHP wordwrap 數組到 Javascript 返回錯誤

慕容708150 2023-04-14 15:15:42
運行以下代碼時出現控制臺錯誤:<?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>控制臺錯誤:Uncaught SyntaxError: missing ) after argument list。哪里有問題?
查看完整描述

1 回答

?
肥皂起泡泡

TA貢獻1829條經驗 獲得超6個贊

正如@u_mulder 指出的那樣,您必須將引號轉義'為:


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


查看完整回答
反對 回復 2023-04-14
  • 1 回答
  • 0 關注
  • 116 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號