首页 > 编程技术 > php

让你不再恐惧--轻松接触 PHP专题

发布时间:2016-11-25 17:36

曾几何时,php之火在中国的大地燃烧,那熊熊烈火,至今也不因 .net 而熄灭!有理由相信,php 的高效运行效率,它的丰富免费资料,可以让它继续生存。
  介绍 php 又怎么会忘记 php 的老换档 mysql 数据库呢,此两者常常成双成对,出双入对,就像影子一样,你不离开我,我不离开你!
  小编辑为此整理了下面的专题教程,为 php 入门者提供方便。
php
  PHP入门速成
  PHP的安装
  变量的变量,PHP 和 你
  通过PHP连接MYSQL的两种方法
  建立灵巧结构的PHP程序
mysql
  在服务器上安装、使用MySQL的注意事项
  MySQL数据库备份

前一段时间我接触到DEC Tru64 Unix 我在上面装了PHP+APACHE,可以用提供的mail函数始终不能正常发信,于是自编了一个函数,它利用UNIX下的管道和PHP的SOCK函数进行发信,经过实验非常驻成功,下面是此函数原代码。
function mymail($mto,$mcc,$msubject,$mbody)
{
$from="webmaster@backhome.com.cn";
$sign = " ";//随你便写些什么
$sendmailpath="/usr/lib/sendmail";//Semdmail路径
$bound = "========_".uniqid("BCFMail")."==_";//分界符
$headers = "MIME-Version: 1.0 ".
"Content-Type: multipart/mixed; boundary="$bound" ".
"Date: ".date("D, d M H:i:s Y ")." ".
"From: $from ".
"To: $mto ".
"Cc: $mcc ".
"Subject: $msubject ".
"Status: ".
"X-Status: ".
"X-Mailer: MY Email Interface ".
"X-Keywords: ";
$content="--".$bound." "."Content-Type:text/plain;charset="GB2312" ".$mbody.$sign." ";
$end = " "."--".$bound."-- ";
$sock = popen("$sendmailpath -t -f 'webmaster@backhome.com.cn'",'w');
fputs($sock, $headers);
fputs($sock, $content);
fputs($sock, $end);
fputs($sock, ". ");
fputs($sock, "QUIT ");
pclose($sock);
}



<?php
/* $Id: ftp.php,v 2.2 2002/03/12 23:21:28 pauls Exp $ */
/* This software came from http://inebria.com/ */
/* Copyright (c) 2000
        Paul Southworth.    All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote
    products derived from this software without specific prior
    written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.    IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* Configuration Options */
$phpftp_host="localhost";
$phpftp_version="2.2";
/* Comment this out if you don't want the version footer */
以下是一个风格类似windows资源管理器的树型菜单
将下面的脚本包含到你的页面中
另外需要从资源管理器中截取一些gif图片,祥见脚本中的注释
菜单结构文件的格式为:
tree level|item text|item link|link target|last item in subtree
例如
.<b>Demo menu</b>|javascript: alert('This is the demo menu for TreeMenu 1.0');
..<b>目录1</b>
...<b>子目录 1.1</b>
....item 1.1.1|javascript: alert('Item 1.1.1');
....item 1.1.2|javascript: alert('Item 1.1.1');
...item 1.2|javascript: alert('Item 1.2');
...item 1.3|javascript: alert('Item 1.3');
..<b>子目录 2</b>
...item 2.1|javascript: alert('Item 2.1');
...item 2.2|javascript: alert('Item 2.2');
...<b>子目录 2.3</b>
....item 2.3.1|javascript: alert('Item 2.3.1');
....item 2.3.2|javascript: alert('Item 2.3.2');
<?php
// file:tremenu.inc
// PHP TreeMenu
/////////////////
// 初始化 //
/////////////////
$treefile = "demomenu.txt";//设置有菜单结构的文件
if(isset($PATH_INFO))
$script = $PATH_INFO;
else
$script = $SCRIPT_NAME;
//以下图片可截取windows资源管理器中的相应位置的图
$img_expand = "tree_expand.gif";//形如资源管理器中可扩展节点+
$img_collapse = "tree_collapse.gif";//形如资源管理器中已扩展节点-
$img_line = "tree_vertline.gif";//形如|
$img_split = "tree_split.gif";//形如|-
$img_end = "tree_end.gif";//形如L
$img_leaf = "tree_leaf.gif";//形如o
$img_spc = "tree_space.gif";//空白图
//以下是菜单处理脚本
$maxlevel=0;
$cnt=0;
$fd = fopen($treefile, "r");
if ($fd==0) die("treemenu.inc : Unable to open file ".$treefile);
while ($buffer = fgets($fd, 4096))
{
$tree[$cnt][0]=strspn($buffer,".");
$tmp=rtrim(substr($buffer,$tree[$cnt][0]));
$node=explode("|",$tmp);
$tree[$cnt][1]=$node[0];
$tree[$cnt][2]=$node[1];
<?php
//公用函数
//把角度转换为弧度
function deg2Arc($degrees) {
return($degrees * (pi()/180.0));
}
//RGB
function getRGB($color){
$R=($color>>16) & 0xff;
$G=($color>>8) & 0xff;
$B=($color) & 0xff;
return (array($R,$G,$B));
}
// 取得在椭圆心为(0,0)的椭圆上 x,y点的值
function pie_point($deg,$va,$vb){
$x= cos(deg2Arc($deg)) * $va;
$y= sin(deg2Arc($deg)) * $vb;
return (array($x, $y));
}
//3D饼图类
class Pie3d{
var $a; //椭圆长半轴
var $b; //椭圆短半轴
var $DataArray; //每个扇形的数据
var $ColorArray; //每个扇形的颜色 要求按照十六进制书写但前面不加0x
//为边缘及阴影为黑色
function Pie3d($pa=100,$pb=60,$sData="100,200,300,400,500", $sColor="ee00ff,dd0000,cccccc,ccff00,00ccff")
{
$this->a=$pa;
$this->b=$pb;
$this->DataArray=split(",",$sData);
$this->ColorArray=split(",",$sColor);
}
function setA($v){
$this->a=$v;
}
function getA(){
return $this->a;
}
function setB($v){
$this->b=$v;
}
function getB(){
return $this->b;
}
function setDataArray($v){
$this->DataArray=split(",",$v);
}
function getDataArray($v){
return $this->DataArray;
}
function setColorArray($v){
$this->ColorArray=split(",",$v);
}
function getColorArray(){
return $this->ColorArray;
}

function DrawPie(){
$image=imagecreate($this->a*2+40,$this->b*2+40);
$PieCenterX=$this->a+10;
$PieCenterY=$this->b+10;
$DoubleA=$this->a*2;
$DoubleB=$this->b*2;
list($R,$G,$B)=getRGB(0);
$colorBorder=imagecolorallocate($image,$R,$G,$B);
标签:[!--infotagslink--]

您可能感兴趣的文章: