background image

if

(!function_exists('file_put_contents')) { 

function

 

file_put_contents

(

$filename

,

$data

) { 

$fp

=

fopen

(

$filename

,"wb"); 

fwrite(

$fp

,

$data

); 

fclose(

$fp

); 



?> 
8.get_defined_functions 
返回一个数组,得到所有已定义的

php 函数。 

例如

一览

php 代码如下:

 
<?php 

$arr

 = get_defined_functions(); 

print_r(

$arr

); 

?> 
 
axgle 点评:这下您知道所有的函数名了吧。若您想了解某个函数的用法,可使用形如 
9.get_declared_classes 
返回一个数组,得到所有已定义的

php 类。 

例如

一览

php 代码如下:

 
<?php 

$arr

 = get_declared_classes(); 

print_r(

$arr

); 

?> 
 
axgle 点评:相信本函数你可以在例 8 运行之后看到。在 php4 中运行本函数,只能得到寥寥无
几的几个类;但若你使用

php5,那么本例中你将看到几十个预定义的 php 类!可见 php5 在

面向对象方面增强了很多。

 

10.

exit

 

输出消息并且停止当前脚本。

(注:和

echo

一样,这不是一个

"函数",而是一个"语句")。 

例如

<?php 

echo

 "语句 1"; 

exit

("下面的语句 2 不会输出"); 

echo

 "语句 2"; 

?> 
axgle 点评:调试程序,查找出错的位置等比较有用. 
有用的

PHP 函数还有很多,还有一些非常有趣的 PHP 函数可以分享,有时间我再介绍。