Maison > Article > développement back-end > php有办法实现像这样输出js代码?该怎么解决
php有办法实现像这样输出js代码?
比如有个变量值是这样的
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->$a = "<script>window.location.href='http://xxx.com';</script>";
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><script>window.location.href='http://xxx.com';</script>
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><script>window.location.href='http://xxx.com';</script>
$a = "<script>window.location.href='http://xxx.com';</script>"; $b = htmlspecialchars($a); echo $b; //result: <script>window.location.href='http://xxx.com';</script> //source: <script>window.location.href='http://xxx.com';</script> <div class="clear"> </div>