php5新函数

php5发布有一段时间了,不过对于php的函数还停留在php4甚至更早,这样就重复这造轮子了,看了看手册和网上的资料整理一部分php5的函数。

1.filter_var(str,int filter) 这个函数是用来验证邮箱地址 url等地址,可以用php自己默认定义的,也可以自己定义filter来匹配

var_dump(filter_var('[email protected]', FILTER_VALIDATE_EMAIL));
var_dump(filter_var('example.com', FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED));
上面将输出
string(15) "[email protected]"
bool(false)

 2.debug_print_backtrace打印程序的调用堆栈信息,比以前的echo print好用,比xdebug简单

<?php
// include.php file

function a() {
    b();
}

function b() {
    c();
}

function c(){
    debug_print_backtrace();
}

a();

?> 
//上面将输出

#0  eval() called at [/tmp/include.php:5]
#1  a() called at [/tmp/include.php:17]
#2  include(/tmp/include.php) called at [/tmp/test.php:3]

#0  c() called at [/tmp/include.php:10]
#1  b() called at [/tmp/include.php:6]
#2  a() called at [/tmp/include.php:17]
#3  include(/tmp/include.php) called at [/tmp/test.php:3]
 

你可能感兴趣的:(php5 新函数)