Home >Backend Development >PHP Tutorial >Example of php custom function
This article shares some simple examples of custom functions in PHP, which can be used as a reference for friends in need.
1, Example of php custom function <html> <head> <title>定义一个函数</title> </head> <body> <?php function bighello(){ print "<h1>HELLO!</h1>"; } bighello(); ?> </body> </html> 2, Custom function to print text on the page <HTML> <HEAD> <TITLE>打印文本-bbs.it-home.org</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. Declare a simple php custom function <?php function aFunction(){ print "音乐是生活的一种方式"; } aFunction(); ?> 4, Create custom function from string <? $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); ?> |