Blogger Information
Blog 8
fans 0
comment 0
visits 11617
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php函数
BlogofDaniel
Original
846 people have browsed it

php函数

php内建函数:超过 1000 个,系统自带调用即可

function_exists("函数名") //判断函数是否存在,返回值boolean



语法:

<?php

function functionName($参数1=默认值,$参数2)

{

    // 要执行的代码

}

?>

PHP 函数准则:

1.函数的名称应该提示出它的功能

2.函数名称以字母或下划线开头(不能以数字开头)

参数

形参:定义函数是的参数

实参:调用时传入的参数


参数的传递方式

传值

传地址


默认值:设置初始函数的默认值,一般写在函数最后


返回值:将结果返回到函数体外,本身不具备输出功能。遇到return函数立即停止执行


*变量函数:

定义:多个函数时,可以将函数名存到一个变量中,这种方法就叫做变量函数

作用:可以动态的调用不同的函数,节省了判断条件的语句和代码,节省时间

  格式:

函数名(); 

变量 = "函数名";

变量();

*递归函数:

定义:封装函数时在函数内调用本函数

*内置函数:

1.func_get_args()

功能:这个函数返回的是包含当前函数所有参数的一个数组

2.func_get_arg(数组元素标示符)

功能:函数返回的是指定位置的参数的值 

参数:调用函数的参数的位置(数组元素表示符)

   3.func_num_args()

功能:这个函数返回的是当前函数的参数数量 返回的是数字



Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!