ITeye博客

php5新函数

myfreespace · 2011-11-18 14:29 · Web前端 · Markdown

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

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

var_dump(filter_var('bob@example.com', FILTER_VALIDATE_EMAIL));
var_dump(filter_var('example.com', FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED));
上面将输出
string(15) "bob@example.com"
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]

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。