例1
复制代码 代码如下:
<html>
<head>
<title>php函数指定默认值-www.zzvips.com</title>
</head>
<body>
<?php
function printMe($param = NULL)
{
print $param;
}
printMe("This is test");
printMe();
?>
<html>
<head>
<title>php函数指定默认值-www.zzvips.com</title>
</head>
<body>
<?php
function printMe($param = NULL)
{
print $param;
}
printMe("This is test");
printMe();
?>
</body>
</html>
输出结果:
This is test
例2 php函数参数默认值的使用范例,php函数参数中设置和使用默认值。
复制代码 代码如下:
<html>
<head>
<title>php函数参数默认值 – www.zzvips.com</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>
<html>
<head>
<title>php函数参数默认值 – www.zzvips.com</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>
相关文章
猜你喜欢
- 64M VPS建站:如何选择最适合的网站建设平台? 2025-06-10
- ASP.NET本地开发时常见的配置错误及解决方法? 2025-06-10
- ASP.NET自助建站系统的数据库备份与恢复操作指南 2025-06-10
- 个人网站服务器域名解析设置指南:从购买到绑定全流程 2025-06-10
- 个人网站搭建:如何挑选具有弹性扩展能力的服务器? 2025-06-10