- $text = strip_tags($input, " ");
8.比较两个字符串
比较两个字符串,以确保它们是相同的。例如,判断用户第一次与第二次输入的密码是否相同,你可以使用substr_compare()函数来很容易的现实:
- $pswd = "secret"; $pswd2 = "secret";
- if (! strcmp($pswd, $pswd2)) { echo "The passwords are not identical!"; }
如果你想判断两个字符串不区分大小写,可以使用strcasecmp()函数。
9.转换换行符
在本文中我介绍了如何轻松转换成超超链接的URL,现在介绍nl2br()函数,这个函数能够帮助你将任何换行符转换成HTML标签。
- $comment = nl2br($comment);
10.应用自动换行
应用自动换行,你可以使用PHP中的这个函数:wordwrap():
- $speech = "Four score and seven years ago our fathers brought forth,
- upon this continent, a new nation, conceived in Liberty,
- and dedicated to the proposition that all men are created equal.";
- echo wordwrap($speech, 30);
执行上面的代码,结果是:
- Four score and seven years ago our fathers brought forth,
- upon this continent, a new nation, conceived in Liberty,
- and dedicated to the proposition that all men are created equal.
原文地址:http://phpbuilder.com/columns/Jason_Gilmore060210.php3