找回密码
 立即注册
搜索
热搜: 生活 中国

PHP函数介绍

[复制链接]
admin 发表于 2013-10-3 15:20:43 | 显示全部楼层 |阅读模式
PHP函数介绍

PHP函数介绍

在开发过程中,经常要重复某种操作或处理,如数据查询、字符操作等,如果每个模块的操作都要重新输入一次代码,不仅今程序员头痛不已,而且对于代码的后期维护及运行效果也有着较大的影响,使用PHP函数即可让这些问题迎刃而解。

定义和调用函数

函数,就是将一些重复使用到的功能写在一个独立的代码中,在需要时单独调用。创建函数的基本语法格式如下:

  1. function fun_name($str1,$str2...$strn{
  2. fun_body;
  3. }
复制代码

function: 为声明自定义函数时必须使用到的关键字

fun_name: 为自定义函数的名称。

$str1...$strn: 为函数的参数

fun_body: 为自定义函数的主体,是功能实现部分。

当函数被定义后,所要做的就是调用这个函数。调用函数的操作十分简单,只需要引用函数名并赋予正确的参数,既可完成函数的调用。

PHP function introduction

In the development process, often to repeat an action or process, such as data query, manipulate characters, etc., if the operation of each module to re-enter a code, not just programmers headache today, but also for ongoing maintenance and operation of the code effect also has a greater influence, using the PHP function can make these problems immediately.

Defining and calling functions

Function is to re-use some of the functions to write the code in a separate, single call when needed. The basic syntax for creating functions are as follows:

  1. function fun_name($str1,$str2...$strn{
  2. fun_body;
  3. }
复制代码

function: to declare custom functions must be used to keyword

fun_name: The name of the custom function.

$str1...$strn: as a function of parameters

fun_body: custom body of the function is to achieve some functionality.

When the function is defined, have to do is call this function. Calling function operation is very simple, only need to reference the function name and given the right parameters, can complete function call.

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|生活导航|生活导航 ( 新ICP备12003026-1号 )

GMT+8, 2024-5-10 01:50 , Processed in 0.079849 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表