php的家

php的一些小东西

fpdf

<?php require(‘chinese.php’); class PDF extends PDF_Chinese { function Header() //设置页眉 { $this->SetFont(‘GB’, »,10); $this->Write(10,’XX公司产品名录’); $this->Ln(20); //换行 } function Footer() //设置页脚 { $this->SetY(-15); $this->SetFont(‘GB’, »,10); $this->Cell(0,10,’第’.$this->PageNo().’页’); } } $conn = mysql_connect(« localhost », « root », «  »); //连接数据库 mysql_select_db(« product », $conn); //执行SQL $query_rs_prod = « SELECT * FROM product ORDER BY prod_id »; $rs_prod = mysql_query($query_rs_prod, $conn) or die(mysql_error()); $row_rs_prod = mysql_fetch_assoc($rs_prod); $totalRows_rs_prod = mysql_num_rows($rs_prod);

fpdf Read More »

转帖 php 检测

//———————————————————————- //———————————————————————- // // 【文件名】: c_check.inc // 【作 用】: 通用检测函数集 // 【作 者】: 天灰 // // 【最后修改日期】: 2001/05/11[cxx] // 【变量定义规则】:‘C_’=字符型,‘I_’=整型,‘N_’=数字型,‘L_’=布尔型,‘A_’=数 组型 //———————————————————————- //———————————————————————- // ※CheckMoney($C_Money) 检查数据是否是 99999.99格式 // ※CheckEmailAddr($C_mailaddr) 判断是否为有效邮件地 址 // ※CheckWebAddr($C_weburl) 判断是否为有效网址 // ※CheckEmpty($C_char) 判断字符串是否为空 // ※CheckLengthBetween($C_char, $I_len1, $I_len2=100) 判断是否为指定长度内 字符串 // ※CheckUser($C_user) 判断是否为合法用户名 // ※CheckPassword($C_passwd) 判断是否为合法用户密 码 // ※CheckTelephone($C_telephone) 判断是否为合法电话号 码 //

转帖 php 检测 Read More »

html加音乐

加音乐有好多方法 例子1 <embed rc= »http://r2046.com/MP3/BB.MP3″ width=300 height=40 controls=ControlPanel loop=true autostart=true volume=100 type=audio/x-pn-realaudio-plugin Initfn=load-types mime-types=mime.types > 一:音乐的格式:   格式一:<embed src=媒体音乐地址 autostart=是否自动播放 loop=是否循环播放         widht=播放界面的宽度 height=播放界面的高度 type=插件类型>  例:<P align=center><embed src=http://dda.ipchina.org/mymp3/wtrack08.mp3 autostart=true loop=true widht=760 height=45 type=audio/mpeg></EMBED>   格式二:<embed src=媒体音乐地址 autostart=是否自动播放   loop=是否循环播放 hidden=播放器是否可见(true) type=插件类型>  例:<embed src=http://music.cnnb.com.cn/music/M/蜜雪薇琪/Kissy/2.wma autostart=true loop=true hidden=true type=audio/mpeg></EMBED>   格式三:<EMBED align=center src=地址 width=宽度 height=高度 type=值></P>  例:<P align=center><EMBED

html加音乐 Read More »

curl 的几个例子

Your first Curl scripts From Practical PHP Programming resource curl_init ( [string url]) bool curl_setopt ( resource curl_handle, string option, mixed value) mixed curl_exec ( resource curl_handle) mixed curl_close ( resource curl_handle) The first Curl script we are going to look at is the simplest Curl script that is actually useful – it will load

curl 的几个例子 Read More »

初学者学习PHP开发应该掌握的几段精华代码

初学者学习PHP开发应该掌握的几段精华代码 转于 :网页教学网 经典循环例子 <HTML><HEAD><TITLE>经典循环例子</TITLE></HEAD><BODY><? for($counter = 1; $counter <= 6; $counter++)        //循环6次 { print(« <B>counter is $counter</B><BR>\n »);    //打印6次 }    ?></BODY></HTML> for的高级运用 <HTML><HEAD><TITLE>for的高级运用</TITLE></HEAD><BODY><? /*  ** 打印必要的说明文字  */ print(« <B>距离星期一还有几天?</B>\n »); print(« <OL>\n »); for($currentDate = date(« U »);             //定义$currentDate时间格式 date(« l », $currentDate) != « Monday »;     //判断是不是当前系统时间是Monday $currentDate += (60 * 60 * 24))        //当前时间加上1天 { /*  ** 打印时间名称  */ print(« <LI> » . date(« l », $currentDate) . « \n »); } print(« </OL>\n »);?></BODY></HTML> 函数的简单调用: <HTML><HEAD><TITLE>简单的函数</TITLE></HEAD><BODY><FONT SIZE=5><? function printBold($inputText)            //定义function printBold() { print(« <B> » . $inputText . « </B> »);    ////打印$inputText } print(« 这行没有加重!<BR>\n »);            //直接打印字符串 printBold(« 这行加重了!!! »);            //调用function printBold()函数 print(« <BR>\n »); print(« 这行没有加重!<BR>\n »);            //直接打印字符串?></FONT></BODY></HTML> 有返回值的函数 <HTML><HEAD><TITLE>有返回值的函数</TITLE></HEAD><BODY><FONT SIZE=5><? function makeBold($inputText)        //定义function makeBold()函数 { $boldedText = « <B> »; $boldedText .= $inputText; $boldedText .= « </B> »; return($boldedText);        //返回变量$boldedText } print(« 这行没有加重!!!<BR>\n »);    //直接打印字符串     print(makeBold(« 这行被加重了!!! ») . « <BR>\n »);//调用function makeBold()函数 print(« 这行没有加重!!!<BR>\n »);    //直接打印字符串?></SIZE></BODY></HTML> 有默认参数的函数 <HTML><HEAD><TITLE>有默认参数的函数</TITLE></HEAD><BODY><FONT SIZE=5><? function printColored($Text, $Color= »black »)        //定义function函数 { print(« <FONT COLOR=\ »$Color\ »>$Text</FONT> »);    //获取字符串的内容和颜色 } printColored(« 这是黑颜色的字! »);            //调用function函数

初学者学习PHP开发应该掌握的几段精华代码 Read More »

pear 的安装

PEAR的安装 作者: EastSon go-pear.orggo-pear.org是一个WEB站点,这个站点很特殊,里面就只有一个文件,只一个单独的PHP脚本,你可以下载并且执行它。这个文件将执行最近的稳定发行包。go-pear是交互平台,可以让你你在你的服务器上面用命令行来获得PEAR。PHP发行包里面有一个特殊的PEAR安装包,另一方面go-pear提供了一个最新稳定版的PEAR发行包。当然go-pear不知道你的目录结构,便可以计算出,来完成PEAR的安装过程。前提:因为go-pear是用PHP写的一个脚本,因此你必须在服务器上有一个PHP 的CGI或CLI程序来执行这个脚本。默认情况下CLI程序已经随着PHP模块安装了。试着运行php v 来看一下是否可用: PHP 5.0.0 (cli), Copyright (c) 1997-2004 The PHP GroupZend Engine v2.0, Copyright (c) 1998-2004 Zend Technologies 注:在我的Windows平台上PHP5.1.6上面要使用php –v 来执行这个命令,下面有好多命令一样。默认情况下php命令行程序在UNIX下安装于 /usr/local/bin 在Windows下安装于 C:\php 。在Windows下PHP的CLI版程序也许叫做php-cli。得到PEAR如果你的PHP安装包没有包含PEAR,你可以使用go-pear做为通程序来获得PEAR。前提是你需要一个已安装的GLI或CGI版本的PHP。你可以下载go-pear脚本并且执行它,像下面这样在命令行中执行:$lynx source http://go-pear.org | php这个脚本从http://go-pear.org获得脚本内容,并由PHP来执行。如果你的系统上lynx无效,可以用其它的方法来直接获得go-pear:$wget O- http://go-pear.org | php 使用GNUS wgetfetch o http://go-pear.org |php 使用fetch在FreeBSDGET http:/go-pear.org | php 使用Perl LWP的GET工具。在Windows平台,你可以使用PHP的URL流来获得,这个要求url_inclues在php.ini中没有被禁用。C:\>php-cli r “include(‘http://go-pear.org’);”还有一种就是直接用浏览器打开http://go-pear.org,把首页另存为go-pear.php然后在命令行中运行。C:\php go-pear.php输出也许像下面这样: Welcome to go-pear!

pear 的安装 Read More »

Panier