search
Homephp教程php手册php入门学习知识点七 PHP函数的基本应用_php基础

复制代码 代码如下:

/*
* 简单的函数
*/
function fontBold($con){
return "$con";
}
$str="简单的函数测试!";
echo "普通文本:$str
";
echo "加粗文本:".fontBold($str)."";
/*
* 带可选参数的函数
*/
function fontColor($con,$color="bule"){
return "$con";
}
$str="颜色测试";
echo $str;
echo fontColor($str."这是不带颜色参数的(默认为蓝色)!");
echo fontColor($str,"red"."这是带颜色参数的(默认为红色!)");
/*
* 递归函数
*/
function chckint($Num){
if($Num>1){
return chckint($Num-1);
}else if($Numreturn chckint(($Num*-1)-1);
}else{
if($Num>0 && $Numreturn false;
}else if($Num){
return true;
}
}
}
$Num=3;
if(chckint($Num)){
echo $Num."是整数!";
}else{
echo $Num."不是整数";
}
/*
*动态调用函数
*/
function write($con){
echo "$con";
}
function writeBold($con){
echo "$con";
}
$myFupnction="write";
$myFupnction("这是动态调用函数不加粗的例子!");
$myFupnction="writeBold";
$myFupnction("这是动态调用加粗的例子!")
?>
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.