例1
復(fù)制代碼 代碼如下:
<html>
<head>
<title>php函數(shù)指定默認(rèn)值-</title>
</head>
<body>
<?php
function printMe($param = NULL)
{
print $param;
}
printMe("This is test");
printMe();
?>
</body>
</html>
輸出結(jié)果:
This is test
例2 php函數(shù)參數(shù)默認(rèn)值的使用范例,php函數(shù)參數(shù)中設(shè)置和使用默認(rèn)值。
復(fù)制代碼 代碼如下:
<html>
<head>
<title>php函數(shù)參數(shù)默認(rèn)值 - </title>
</head>
<body>
<?php
function textonweb ($content, $fontsize=3){
echo "<font SIZE=$fontsize>$content</font>";
}
textonweb ("A <br />", 7);
textonweb ("AA.<br />");
textonweb ("AAA. <br />");
textonweb ("AAAA! <br />");
?>
</body>
</html>
新聞熱點(diǎn)
疑難解答