Home  >  Article  >  Backend Development  >  PHP language structure

PHP language structure

不言
不言Original
2018-04-23 16:15:201629browse

这篇文章介绍的内容是关于PPHP语言结构,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下



1、内置函数

第一次运行结果:
PHP language structure
第二次运行结果:
PHP language structure


2、自定义函数
①自定义和调用函数

PHP language structure
②向函数传递参数值

PHP language structure


3、条件控制结构
①单一条件分支结构(if)

PHP language structure
②双向条件分支结构(if…else)

PHP language structure
③多向条件分支结构(switch语句)

PHP language structure


4、循环控制结构
①while循环语句

PHP language structure
②do…while循环语句
其中先执行do后面的”命令执行语句”,其中的变量会随着命令的执行发生变化,当此变量通过while后面的条件判断为false时,停止执行“命令执行语句”。

PHP language structure
③foreach循环语句

foeeach(数组 as 数组元素){
对数组元素的操作命令;
}
foreach(数组 as 数组元素值){
对数组元素的操作命令;
}

PHP language structure

相关推荐:

PHP中字符串与正则表达式

The above is the detailed content of PHP language structure. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn