在日常的学习、工作、生活中,肯定对各类范文都很熟悉吧。范文怎么写才能发挥它最大的作用呢?这里我整理了一些优秀的范文,希望对大家有所帮助,下面我们就来了解一下吧。
php技巧分享篇一
php 独特的.语法混合了c、java、perl以及php自创的语法。它可以比cgi或者perl更快速地执行动态网页。下面就来和大家说说几个php技巧吧。
方法一:header("location: ");
方法二:echo "";
方法三:echo "";
function browse_infor()
{
$browser="";$browserver="";
$browsers =array("lynx","mosaic","aol","opera","java","macweb","webexplorer","omniweb");
$agent = $globals["http_user_agent"];
for ($i=0; $i<=7; $i++)
{
if (strpos($agent,$browsers[$i]))
{
$browser = $browsers[$i];
$browserver ="";
}
}
if (ereg("mozilla",$agent) && !ereg("msie",$agent))
{
$temp =explode("(", $agent); $part=$temp[0];
$temp =explode("/", $part); $browserver=$temp[1];
$temp =explode(" ",$browserver); $browserver=$temp[0];
$browserver =preg_replace("/([d.]+)/","1",$browserver);
$browserver = " $browserver";
$browser = "netscape navigator";
}
if (ereg("mozilla",$agent) && ereg("opera",$agent))
{
$temp =explode("(", $agent); $part=$temp[1];
$temp =explode(")", $part); $browserver=$temp[1];
$temp =explode(" ",$browserver);$browserver=$temp[2];
$browserver =preg_replace("/([d.]+)/","1",$browserver);
$browserver = " $browserver";
$browser = "opera";
}
if (ereg("mozilla",$agent) && ereg("msie",$agent))
{
$temp = explode("(", $agent); $part=$temp[1];
$temp = explode(";",$part); $part=$temp[1];
$temp = explode(" ",$part);$browserver=$temp[2];
$browserver =preg_replace("/([d.]+)/","1",$browserver);
$browserver = " $browserver";
$browser = "internet explorer";
}
if ($browser!="")
{
$browseinfo = "$browser$browserver";
}
else
{
$browseinfo = "unknown";
}
return $browseinfo;
}
//调用方法$browser=browseinfo() ;直接返回结果
function osinfo() {
$os="";
$agent = $globals["http_user_agent"];
if (eregi('win',$agent) && strpos($agent, '95')) {
$os="windows 95";
}
elseif (eregi('win 9x',$agent) && strpos($agent, '4.90')) {
$os="windows me";
}
elseif (eregi('win',$agent) && ereg('98',$agent)) {
$os="windows 98";
}
elseif (eregi('win',$agent) && eregi('nt 5.0',$agent)) {
$os="windows 2000";
}
elseif (eregi('win',$agent) && eregi('nt',$agent)) {
$os="windows nt";
}
elseif (eregi('win',$agent) && eregi('nt 5.1',$agent)) {
$os="windows xp";
}
elseif (eregi('win',$agent) && ereg('32',$agent)) {
$os="windows 32";
}
elseif (eregi('linux',$agent)) {
$os="linux";
}
elseif (eregi('unix',$agent)) {
$os="unix";
}
elseif (eregi('sun',$agent) && eregi('os',$agent)) {
$os="sunos";
}
elseif (eregi('ibm',$agent) && eregi('os',$agent)) {
$os="ibm os/2";
}
elseif (eregi('mac',$agent) && eregi('pc',$agent)) {
$os="macintosh";
}
elseif (eregi('powerpc',$agent)) {
$os="powerpc";
}
elseif (eregi('aix',$agent)) {
$os="aix";
}
elseif (eregi('hpux',$agent)) {
$os="hpux";
}
elseif (eregi('netbsd',$agent)) {
$os="netbsd";
}
elseif (eregi('bsd',$agent)) {
$os="bsd";
}
elseif (ereg('osf1',$agent)) {
$os="osf1";
}
elseif (ereg('irix',$agent)) {
$os="irix";
}
elseif (eregi('freebsd',$agent)) {
$os="freebsd";
}
if ($os=='') $os = "unknown";
return $os;
}
//调用方法$os=os_infor() ;
$mime_types = array(
'gif' => 'image/gif',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'bmp' => 'image/bmp',
'png' => 'image/png',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'pict' => 'image/x-pict',
'pic' => 'image/x-pict',
'pct' => 'image/x-pict',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'psd' => 'image/x-photoshop',
'swf' => 'application/x-shockwave-flash',
'js' => 'application/x-javascript',
'pdf' => 'application/pdf',
'ps' => 'application/postscript',
'eps' => 'application/postscript',
'ai' => 'application/postscript',
'wmf' => 'application/x-msmetafile',
'css' => 'text/css',
'htm' => 'text/html',
'html' => 'text/html',
'txt' => 'text/plain',
'xml' => 'text/xml',
'wml' => 'text/wml',
'wbmp' => 'image/',
'mid' => 'audio/midi',
'wav' => 'audio/wav',
'mp3' => 'audio/mpeg',
'mp2' => 'audio/mpeg',
'avi' => 'video/x-msvideo',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
'lha' => 'application/x-lha',
'lzh' => 'application/x-lha',
'z' => 'application/x-compress',
'gtar' => 'application/x-gtar',
'gz' => 'application/x-gzip',
'gzip' => 'application/x-gzip',
'tgz' => 'application/x-gzip',
'tar' => 'application/x-tar',
'bz2' => 'application/bzip2',
'zip' => 'application/zip',
'arj' => 'application/x-arj',
'rar' => 'application/x-rar-compressed',
'hqx' => 'application/mac-binhex40',
'sit' => 'application/x-stuffit',
'bin' => 'application/x-macbinary',
'uu' => 'text/x-uuencode',
'uue' => 'text/x-uuencode',
'latex'=> 'application/x-latex',
'ltx' => 'application/x-latex',
'tcl' => 'application/x-tcl',
'pgp' => 'application/pgp',
'asc' => 'application/pgp',
'exe' => 'application/x-msdownload',
'doc' => 'application/msword',
'rtf' => 'application/rtf',
'xls' => 'application/-excel',
'ppt' => 'application/-powerpoint',
'mdb' => 'application/x-msaccess',
'wri' => 'application/x-mswrite',
);
header("content-type:application/-excel");
header("content-disposition:filename=");
echo "test1 ";
echo "test2 ";
echo "test1 ";
echo "test2 ";
echo "test1 ";
echo "test2 ";
echo "test1 ";
echo "test2 ";
echo "test1 ";
echo "test2 ";
echo "test1 ";
echo "test2 ";
?>
// .xls等文件格式了
s("content_relate");
【几个php技巧】相关文章:
php几个经典算法题
08-22
关于php数组的几个基本操作
10-06
php学习路线以及php优化技巧
09-07
php常用开发技巧
10-15
php代码优化技巧
09-02
php性能优化技巧
09-01
总结php初学者常犯的几个错误
09-27
php性能优化的技巧
09-28
php常用的技术技巧
10-31
【本文地址:http://www.xuefen.com.cn/zuowen/2778649.html】