<?php
No return value, no parameter
/*function CreateTable () {
$col = "";
Echo $col;
$cindex = 0;
while ($cindex <10) {
$col. = "<td></td>";
$cindex + +;
}
$rindex = 0;
$row = "";
while ($rindex <10) {
$row. = "<tr> $col </tr>";
$rindex + +;
}
echo "<table width= ' height= ' border=1 style= ' background-color:red; ' > $row </table> ";
}
CreateTable ();
No return value, with parameters
function Createtablebynum ($colNum, $rowNum) {
$col = "";
Echo $col;
$cindex = 0;
while ($cindex < $colNum) {
$col. = "<td></td>";
$cindex + +;
}
$rindex = 0;
$row = "";
while ($rindex < $rowNum) {
$row. = "<tr> $col </tr>";
$rindex + +;
}
echo "<table width= ' height= ' border=1 style= ' background-color:red; ' > $row </table> ";
}
Createtablebynum (bis);
There are return values, parameters
Function: output the corresponding table according to the parameters passed in
Parameters: Shaping, number of columns, number of rows
Return value: Outputs the table string for the specified row and column
function Createtablebynumandreturn ($colNum, $rowNum) {
$col = "";
Echo $col;
$cindex = 0;
while ($cindex < $colNum) {
$col. = "<td></td>";
$cindex + +;
}
$rindex = 0;
$row = "";
while ($rindex < $rowNum) {
$row. = "<tr> $col </tr>";
$rindex + +;
}
Return "<table width= ' height= ' border=1 style= ' background-color:red; ' > $row </table> ";
}*/
echo Createtablebynumandreturn (8,8);
/* $a = 100;
$b = 800;
function Outputvar () {
Global $a;//declares a variable that uses the Globals
echo $a;
echo $GLOBALS [' a ']. " ". $GLOBALS [' B ']." <br/> ";
$GLOBALS [' A ']=400;
}
Outputvar ();
echo $a. " <br/> ";
Function Outputvarbyref (& $num) {//value type pass through the value, does not affect the original value, use the & symbol to pass the variable address of the value type, so it affects the original value
$num = 500;
}
Outputvarbyref ($a);
echo $a;
function counts () {
static $index = 0;
echo $index. " <br/> ";
$index + +;
}
for ($i =0; $i <3; $i + +) {
COuntS ();
}
CounTs ();
Echo function_exists ("Opendir"); */
Intrinsic functions
/*function parent () {
echo "This is the parent function";
function Sub1 () {
echo "This is the big son";
}
function Sub2 () {
echo "This is the youngest son";
}
}
Parent ();
Sub1 ();
Sub2 ();
PHP function methods