1,php自定义函数的例子
<html>
<head>
<title>定义一个函数</title>
</head>
<body>
<?php
function bighello(){
print "<h1>HELLO!</h1>";
}
bighello();
?>
</body>
</html>
2,在页面上打印文本的自定义函数
<HTML>
<HEAD>
<TITLE>打印文本-www.jb200.com</TITLE>
</HEAD>
<BODY>
<?php
function textonweb ($content, $fontsize) {
echo "<FONT SIZE=$fontsize>$content</FONT>";
}
textonweb ("A <BR>", 7);
textonweb ("AA. <BR>", 3);
textonweb ("AAA. <BR>", 3);
textonweb ("AAAA! <BR>", 3);
?>
</BODY>
</HTML>
3,声明一个简单的php自定义函数
<?php
function aFunction(){
print "音乐是生活的一种方式";
}
aFunction();
?>
4,从字符串创建自定义函数
<?
$lambda =create_function('$a,$b','return(strlen($a)-strlen($b));');
$array = array('really long string here,boy', 'this', 'middling length',
'larger');
usort($array,$lambda);
print_r($array);
?>