Home > Backend Development > PHP Tutorial > PHP introductory learning knowledge point 7 Basic application of PHP functions_PHP tutorial

PHP introductory learning knowledge point 7 Basic application of PHP functions_PHP tutorial

WBOY
Release: 2016-07-21 15:27:14
Original
864 people have browsed it

Copy code The code is as follows:

/*
* Simple function
*/
function fontBold($con){
return "$con";
}
$str="Simple function test!";
echo " Normal text: $str
";
echo "Bold text:".fontBold($str)."";
/*
* Function with optional parameters
*/
function fontColor($con,$color="bule"){
return "$con";
}
$str ="Color test";
echo $str;
echo fontColor($str."This is without color parameters (default is blue)!");
echo fontColor($str," red"."This is with color parameters (default is red!)");
/*
* Recursive function
*/
function chckint($Num){
if( $Num>1){
return chckint($Num-1);
}else if($Num<0){
return chckint(($Num*-1)-1);
}else{
if($Num>0 && $Num<1){
return false;
}else if($Num){
return true;
}
}
}
$Num=3;
if(chckint($Num)){
echo $Num."It’s an integer!";
}else{
echo $Num ."Not an integer";
}
/*
*Dynamic call function
*/
function write($con){
echo "$con";
}
function writeBold($con){
echo "$con";
}
$myFupnction="write";
$myFupnction("This is An example of dynamically calling a function without bolding it! ");
$myFupnction="writeBold";
$myFupnction("This is an example of dynamically calling bold!")
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323821.htmlTechArticleCopy the code as follows: ?php /* * Simple function*/ function fontBold($con){ return " B$con/B"; } $str="Simple function test! "; echo "Normal text: $strbr"; echo "Bold text...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template