標籤:oba order output for 全域 numa ++ index ble
<?php
//無傳回值,無參數
/*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=‘200‘ height=‘200‘ border=1 style=‘background-color:red;‘>$row</table>";
}
//CreateTable();
//無傳回值,有參數
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=‘200‘ height=‘200‘ border=1 style=‘background-color:red;‘>$row</table>";
}
CreateTableByNum(4,4);
//有傳回值,有參數
功能:根據傳入的參數輸出對應的表格
參數:整形,列的數量,行的數量
傳回值:輸出指定行和列的表格字串
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=‘200‘ height=‘200‘ border=1 style=‘background-color:red;‘>$row</table>";
}*/
//echo CreateTableByNumAndReturn(8,8);
/* $a=100;
$b=800;
function outputVar(){
//global $a;//表示聲明使用全域的變數
//echo $a;
echo $GLOBALS[‘a‘]." ".$GLOBALS[‘b‘]."<br/>";
$GLOBALS[‘a‘]=400;
}
outputVar();
echo $a."<br/>";
function outputVarByref(&$num){//實值型別傳遞過程中是將值進行傳遞,不會影響原來的值,使用&符號表示將實值型別的變數地址傳遞,所以會影響原來的值
$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");*/
//內建函式
/*function parent(){
echo "這是父函數";
function sub1(){
echo "這是大兒子";
}
function sub2(){
echo "這是小兒子";
}
}
parent();
sub1();
sub2();
PHP函數方法