|
本文介绍下,php处理特殊字符的几个函数实例,包括strip_tags、htmlspecialchars、addslashes等。有需要的朋友参考下。
分享下,php中特殊字符处理函数的用法,包括strip_tags、htmlspecialchars、addslashes等的用法。 代码:
<html>
<body>
<?php
if ($_POST['submitted'] == "yes"){
$yourname = $_POST['yourname'];
$yourname = trim ($yourname);
$yourname = strip_tags ($yourname);
$yourname = htmlspecialchars ($yourname);
$yourname = addslashes ($yourname);
echo $yourname . "<br />";
?>Try Again<?php
}
if ($_POST['submitted'] != "yes"){
?>
<form action="index.php" method="post">
<p>例子:</p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/xiazai/learn/2594">
<img src="https://img.php.cn/upload/webcode/000/000/000/5a2b9add93ca8711.png" alt="自学 PHP、MySQL和Apache">
</a>
<div class="aritcle_card_info">
<a href="/xiazai/learn/2594">自学 PHP、MySQL和Apache</a>
<p>本书将PHP开发与MySQL应用相结合,分别对PHP和MySQL做了深入浅出的分析,不仅介绍PHP和MySQL的一般概念,而且对PHP和MySQL的Web应用做了较全面的阐述,并包括几个经典且实用的例子。
本书是第4版,经过了全面的更新、重写和扩展,包括PHP5.3最新改进的特性(例如,更好的错误和异常处理),MySQL的存储过程和存储引擎,Ajax技术与Web2.0以及Web应用需要注意的安全</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="自学 PHP、MySQL和Apache">
<span>400</span>
</div>
</div>
<a href="/xiazai/learn/2594" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="自学 PHP、MySQL和Apache">
</a>
</div>
<input type="hidden" name="submitted" value="yes" />
您的名字: <input type="text" name="yourname" maxlength="150" /><br />
<input type="submit" value="Submit" style="margin-top: 10px;" />
</form>
<?php
}
?>
</div>
</body>
</html>登录后复制 |
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号