首页 > 解决方案 > HTML PHP 字符串特殊字符转义

问题描述

只是想知道是否可以使用 PHP 编写链接按钮,字符串中有这么多特殊字符。

  $link='index.php?topic=transactions&content=transaction_adjustment&tx_number='.$tx_number;
  echo '<button type="button" onclick="window.location.href="'.$link.'"">Adjust</button>';

标签: phpescaping

解决方案


尝试以下操作:

 $link='index.php?topic=transactions&content=transaction_adjustment&tx_number='.$tx_number;
 echo '<button type="button" onclick="window.location.href=\''.$link.'\'">Adjust</button>';

推荐阅读