现在开始的是对函数的简单使用,例子是一个将字体加粗的函数,代码如下:
< BODY >
< FONT SIZE = 5 >
<?
function PrintBold( $string )
{
$temp = "<B>";
$temp .= $string;
$temp .= "</B>";
return $temp;
}
print(PrintBold("This is a bold string"));
?>
</FONT>
</BODY>
函数也可以这样写
<BODY>
<FONT SIZE = 5>
<?
function PrintBold( $string )
{
print("<B>".$string."</B>");
}
PrintBold("This is a bold string");
?>
</FONT>
</BODY>
学习PHP往往容易落入面向过程的圈子,熟悉函数的使用及结构化编程会使程序更容易维护和阅读