龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

几个有用的php函数

时间:2014-07-22 14:51来源: 作者: 点击:
分享到:
<无详细内容>
1. exec执行系统命令

exec("ls -a", $out);

print_r($out);

2. php验证字段,验证邮箱

filter_var('bob@example.com', FILTER_VALIDATE_EMAIL)

3.判断是否在集合中出现

in_array("hello", array("good","bad","hello"))//结果 true,找不到返回false

4. file_get_contents

读取文件内容,将文件内所有内容读入到串中。同样可以读入url,用于下载网页内容。

$res = file_get_contents(http://www.baidu.com);

5. str_replace

mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )

字符串替换echo str_replace("world","John","Hello world!")

输出 Hello John
精彩图集

赞助商链接