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!")
?>
http://www.bkjia.com/PHPjc/323821.htmlwww.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...
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