易截截图软件、单文件、免安装、纯绿色、仅160KB

php 字符串函数

一、字符串基础函数
ltrim: 去除连续空白。
trim: 截去字符串首尾的空格。
Chop: 函数从字符串的末端开始删除空白字符或其他预定义字符。(rtrim别名)
<?php
$str = "Hello World!\n\n";
echo $str;
echo chop($str);
?>
输出:
Hello World! Hello World!
htmlspecialchars(string,quotestyle,character-set): 函数把一些预定义的字符转换为 HTML 实体。
预定义的字符是:
& (和号) 成为 &amp;
" (双引号) 成为 &quot;
' (单引号) 成为 &#039;
< (小于) 成为 &lt;
> (大于) 成为 &gt;
例子
<html>
<body>
<?php
$str = "John & 'Adams'";
echo htmlspecialchars($str, ENT_COMPAT);
echo "<br />";
echo htmlspecialchars($str, ENT_QUOTES);
echo "<br />";
echo htmlspecialchars($str, ENT_NOQUOTES);
?>
</body>
</html>浏览器输出:
John & 'Adams'
John & 'Adams'
John & 'Adams'如果在浏览器中查看源代码,会看到这些 HTML:
<html>
<body>
John &amp; 'Adams'<br />
John &amp; &#039;Adams&#039;<br />
John &amp; 'Adams'
</body>
</html>
htmlentities(string,quotestyle,character-set): 将所有的字符都转成 HTML 字符串。
例子
<html>
<body>
<?php
$str = "John & 'Adams'";
echo htmlentities($str, ENT_COMPAT);
echo "<br />";
echo htmlentities($str, ENT_QUOTES);
echo "<br />";
echo htmlentities($str, ENT_NOQUOTES);
?>
</body>
</html>浏览器输出:
John & 'Adams'
John & 'Adams'
John & 'Adams'如果在浏览器中查看源代码,会看到这些 HTML:
<html>
<body>
John &amp; 'Adams'<br />
John &amp; &#039;Adams&#039;<br />
John &amp; 'Adams'
</body>
</html>
nl2br: 将换行字符转成 <br>。
strcmp(string1,string2)函数比较两个字符串。
该函数返回:
0 - 如果两个字符串相等
<0 - 如果 string1 小于 string2
>0 - 如果 string1 大于 string2 
二、字符串大小写转换函数
strtolower: 字符串全转为小写。
strtoupper


相关文档:

随机选择多组数据的其中一组PHP代码

这是随机选择A0-A3四组数据中其中一组PHP代码:
<?php
$A[0]="QQ:<font color=ff32000>7161283</font>";
$A[1]="E_mail:<font color=ff32000>15018499772@139.com</font>";
$A[2]="手机:<font color=ff32000>15018499772</font>";
$A[3]="MSN:<font color=ff32000>chinaa ......

FreeBSD下nginx并支持php配置详解

系统及软件版本
FreeBSD 7.3
Apache-2.2.14-5[ 1.3.42(Unix)]
PHP-5.2.12
MySQL-5.0.90
Freebsd通过port安装nginx
Nginx ("engine x") 是一个高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,它已经在该站点运行超过两 ......

Month of PHP Security Summary

it is 21th of May. The Month of PHP Security
(http://www.php-security.org) is still running and we have reached a
vulnerability count of 40 vulnerabilities, which is nearly as much as we
disclosed during the whole Month of PHP Bugs in 2007. However there are
11 more days until the end of May and ......

在Fedora 12中安装Apache2+PHP5+MySQL(LAMP)

1.
前言
我使用的主机名为server1.example.com
,ip
地址是192.168.0.100
。这些设置可能与你想要的有所不同,所以你必须在适当的地方修改一下。
2
安装MySQL5
用下列命令安装MySQL

yum install mysql mysql-server
然后我们为MySQL
创建系统启动链接(这样的话,MySQL
就会随着系统启动而启动),并启动 ......

ubuntu10.04配置apache+php+mysql

1.安装apache2.0
  sudo apt-get install apache2
  安装后在浏览器中打开:
 
 http://localhost/或者http://127.0.0.1
  如果出现It works!,那证明安装成功。
 
 2.安装PHP
  sudo apt-get install php
5 //安装PHP
5
 
 sudo apt-get install libapache2-mod-php5 //配置APACHE+PHP
  sud ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号