Home > php教程 > PHP源码 > 几个有用的php函数

几个有用的php函数

PHP中文网
Release: 2016-05-25 17:12:01
Original
1079 people have browsed it

几个有用的php函数

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
Copy after login

                   

 以上就是几个有用的php函数的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template