1. About PHP Redirection
Method One: Header ("Location:index.php");
Method Two: Echo "";
Method Three: Echo " ";
2. Get the visitor's browser
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;
}
Call Method $browser=browseinfo (); return results directly
3. Get the visitor's operating system
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 (+, $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;
}
Call Method $os=os_infor ();
4. File Format class
$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/vnd.wap.wbmp,
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/vnd.ms-excel,
ppt = Application/vnd.ms-powerpoint,
MDB = application/x-msaccess,
WRI = Application/x-mswrite,
);
5. PHP generates Excel documents
Header ("Content-type:application/vnd.ms-excel");
Header ("Content-disposition:filename=test.xls");
echo "Test1";
echo "Test2";
echo "Test1";
echo "Test2";
echo "Test1";
echo "Test2";
echo "Test1";
echo "Test2";
echo "Test1";
echo "Test2";
echo "Test1";
echo "Test2";
?>
Change the file header to output. doc. xls file formats
http://www.bkjia.com/PHPjc/532636.html www.bkjia.com true http://www.bkjia.com/PHPjc/532636.html techarticle 1, about the PHP redirection method One: header ("Location:index.php"); method two: echo "scriptwindow.location =" $PHP _self ";/script"; Method Three: Echo " META http-equiv= "Refresh" CONTENT ...