PHP速学教程(入门到精通)
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
PHP如何将HTML字符转义?
在PHP中可以使用“htmlspecialchars()”函数将HTML字符转义,该函数的作用是将特殊字符转换为HTML实体,其用法为“htmlspecialchars($string)”,其参数“$string”代表待转换的字符。
推荐视频教程:《PHP编程从入门到精通(学习路线)》
示例
<?php $new = htmlspecialchars("<a href='test'>Test", ENT_QUOTES); echo $new; // <a>Test</a> ?>
<?php function fixtags($text){ $text = htmlspecialchars($text); $text = preg_replace("/=/", "=""", $text); $text = preg_replace("/"/", """", $text); $tags = "/<(/|)(w*)( |)(w*)([\=]*)(?|(")"""|)(?|(.*)?"(")|)([ ]?)(/|)>/i"; $replacement = ""; $text = preg_replace($tags, $replacement, $text); $text = preg_replace("/=""/", "=", $text); return $text; } ?> an example: <?php $string = " this is smaller < than this<br /> this is greater > than this<br> this is the same = as this<br><a>This is a link</a><br><b>Bold</b> <i>italic</i> etc..."; echo fixtags($string); ?>
推荐教程:《PHP》
php免费学习视频:立即学习
踏上前端学习之旅,开启通往精通之路!从前端基础到项目实战,循序渐进,一步一个脚印,迈向巅峰!
已抢7569个
抢已抢97331个
抢已抢15252个
抢已抢53946个
抢已抢198259个
抢已抢88323个
抢