博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PHP函数方法
阅读量:4597 次
发布时间:2019-06-09

本文共 1719 字,大约阅读时间需要 5 分钟。

<?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();

转载于:https://www.cnblogs.com/phpzhang/p/6059927.html

你可能感兴趣的文章
C/C++中extern和static
查看>>
第一阶段linux结束
查看>>
网络流+二分图模板
查看>>
[MQ]关于ActiveMQ的配置
查看>>
tomcat部署Jenkins并配置jdk、maven、git
查看>>
Lintcode: Digit Counts
查看>>
Leetcode: House Robber
查看>>
adb命令
查看>>
矩阵乘法运算
查看>>
Java 日志组件(三)
查看>>
iphone中button按钮显示为圆形解决
查看>>
SharedPreferences.Editor 的apply()与commit()方法的区别
查看>>
页面编码
查看>>
gulpfile.js(编译sass,压缩图片,自动刷新浏览器)
查看>>
用于解决用户多线路访问的nginx cross isp module
查看>>
vs启动项目提示Web 服务器被配置为不列出此目录的内容。
查看>>
CF140E New Year Garland
查看>>
LeetCode--Remove Linked List Elements--JavaScript
查看>>
[android]深入理解findViewById原理
查看>>
实验四
查看>>