分享一则PHP定义函数代码

yipeiwu_com5年前PHP代码库

先贴代码

复制代码 代码如下:

<?php
    function table(){
        echo "<table align='center' border='1' width='600' cellspacing='0';>";
        echo "<caption><h1>这是表格的标题</h1></caption>";
        for($out=0; $out < 10; $out++ ){
            $bgcolor = $out%2 == 0 ? "#ffffff" : "green";
            $fontcolor = $out%2 == 0 ? "#ffffff" : "#000000";
            echo "<tr bgcolor=".$bgcolor.">";
            for($in=0;$in<10;$in++){
                echo "<td>".($out*10+$in)."</td>";
            };
            echo "</tr>";
        };
        echo "</table>";
    }
    table();
?>

这是一段 PHP  定义函数的代码

tips:

1、注意PHP 的语法格式

2、注意在PHP 中插入Html 代码的方式

3、利用for 循环的时候,注意想清楚,外部循环和里部循环 的差异性

相关文章

PHP关于htmlspecialchars、strip_tags、addslashes的解释

PHP的htmlspecialchars、strip_tags、addslashes是网页程序开发中常见的函数,今天就来详细讲述这些函数的用法: 1.函数strip_tags:去掉 HT...

shopex中集成的站长统计功能的代码简单分析

复制代码 代码如下: <?php //我们的域名,这里可以不唯一的 $domain = 'localhost'; //这个应该是CNZZ授权给shopex的加密密钥,如果错了就不能...

Uncaught exception com_exception with message Failed to create COM object

Uncaught exception com_exception with message Failed to create COM object

在PHP中调用IE使用如下代码: 复制代码 代码如下: browser = new COM("InternetExplorer.Application"); 无法正常调用,直接报错:...

CodeIgniter与PHP5.6的兼容问题

错误提示: A PHP Error was encountered Severity: Notice Message: Only variable references shou...

PHP中的self关键字详解

前言 PHP群里有人询问self关键字的用法,答案是比较明显的:静态成员函数内不能用this调用非成员函数,但可以用self调用静态成员函数/变量/常量;其他成员函数可以用self调用静...