91网首页-91网页版-91网在线观看-91网站免费观看-91网站永久视频-91网站在线播放

LOGO OA教程 ERP教程 模切知識(shí)交流 PMS教程 CRM教程 開發(fā)文檔 其他文檔  
 
網(wǎng)站管理員

ASP / PHP Cross Reference

admin
2012年6月6日 23:32 本文熱度 4410
This is by no means a complete list but it should help you convert ASP to PHP or the other way around. PHP has many more built in commands than ASP (VBScript), so several lines of code in ASP may convert so a single line in PHP. If you have a large application to move from ASP to PHP, the ASP Translator is a free web application that will save you hours of work. It converts comments, variables, if/then, loops, and many commands from ASP to PHP, all in your web browser.

ASP (VBScript)


PHP (v4.3+)


General syntax

ASP Comments, inline
'my dog has fleas
PHP Comments, inline
//my dog has fleas
ASP Comments, block

not available?
PHP Comments, block
ASP, Escaping quotes
""

"var text1=""<img src=\""blank.gif\"">"";"
PHP, Escaping quotes
\" or use ' like javascript

'var text1="<img src=\"blank.gif\">";';
ASP Command termination
None, but only one command per line.
PHP Command termination
Each command must end with ; but
multiple commands per line are allowed.
ASP Screen output
response.write "hello"
PHP Screen output
echo "hello";
ASP Newline characters
vbCrLf

response.write "hello" & vbCrLf
PHP Newline characters
"\n" (must be inside "", not '')

echo "hello \n";
ASP Variable Names
Not case sensitive,
so fName is the same as FNAME
PHP Variable Names
Case sensitive AND must begin with $
so $fName is NOT the same as $FNAME

String Functions

ASP String concatenation
&

fname=name1 & " " & name2
emsg=emsg & "error!"
PHP String concatenation
. and .=

$fname=$name1." ".$name2;
$emsg.="error!";
ASP, Change case
LCase(), UCase()

lowerName=LCase(chatName)
upperName=UCase(chatName)
PHP, Change case
strtolower(), strtoupper()

$lowerName=strtolower($chatName);
$upperName=strtoupper($chatName);
ASP String length
Len()

n=Len(chatName)
PHP String length
strlen()

$n=strlen($chatName);
ASP, Trim whitespace
Trim()

temp=Trim(xpage)
PHP, Trim whitespace
trim() and also ltrim(), rtrim()

$temp=trim($xpage);
ASP String sections
Left(), Right(), Mid() Left("abcdef",3) 
result = "abc"
Right("abcdef",2)
result = "ef"
Mid("abcdef",3)
result = "cdef"
Mid("abcdef",2,4)
result = "bcde"
PHP String sections
substr() substr("abcdef",0,3); 
result = "abc" substr("abcdef",-2);
result = "ef" substr("abcdef",2);
result = "cdef" substr("abcdef",1,4);
result = "bcde"
ASP String search forward, reverse
Instr(), InstrRev() 
x=Instr("abcdef","de")
x=4
x=InstrRev("alabama","a")
x=7
PHP String search forward, reverse
strpos(), strrpos() $x=strpos("abcdef","de"); 
x=3 $x=strrpos("alabama","a"); x=6
ASP String replace
Replace(string exp,search,replace)
temp=Replace(temp,"orange","apple")
temp=Replace(temp,"'","\'")
temp=Replace(temp,"""","\""")
PHP String replace
str_replace(search,replace,string exp)

$temp=str_replace("orange","apple",$temp);
$temp=str_replace("'","\\'",$temp);
$temp=str_replace("\"","\\\"",$temp);
ASP, split a string into an array
Split() 
temp="cows,horses,chickens"
farm=Split(temp,",",-1,1)
x=farm(0)
PHP, split a string into an array
explode() $temp="cows,horses,chickens"; 
$farm=explode(",",$temp);
$x=$farm[0];
ASP, convert ASCII to String
x=Chr(65) x="A"
PHP, convert ASCII to String
$x=chr(65); x="A"
ASP, convert String to ASCII
x=Asc("A") x=65
PHP, convert String to ASCII
$x=ord("A") x=65

Control Structures

ASP, if statements
if x=100 then 
x=x+5
elseif x<200 then
x=x+2
else
x=x+1
end if
PHP, if statements
if ($x==100) { $x=$x+5; } else if ($x<200) { $x=$x+2; } else { $x++; }
ASP, for loops
for x=0 to 100 step 2 
if x>p then exit for
next
PHP, for loops
for ($x=0; $x<=100; $x+=2) { if ($x>$p) {break;} }
ASP, while loops
do while x<100 x=x+1 
if x>p then exit do
loop
PHP, while loops
while ($x<100) { $x++; if ($x>$p) {break;} }
ASP, branching
select case chartName 
case "TopSales"
theTitle="Best Sellers"
theClass="S"
case "TopSingles"
theTitle="Singles Chart"
theClass="S"
case "TopAlbums"
theTitle="Album Chart"
theClass="A"
case else
theTitle="Not Found"
end select
PHP, branching
switch ($chartName) { 
case "TopSales":
$theTitle="Best Sellers";
$theClass="S";
break;
case "TopSingles":
$theTitle="Singles Chart";
$theClass="S";
break;
case "TopAlbums":
$theTitle="Album Chart";
$theClass="A";
break;
default:
$theTitle="Not Found";
}
ASP functions
Function myFunction(x) 
myFunction = x*16 'Return value
End Function
PHP functions
function myFunction($x) { return $x*16; //Return value }

HTTP Environment

ASP, Server variables
Request.ServerVariables("SERVER_NAME") 
Request.ServerVariables("SCRIPT_NAME")
Request.ServerVariables("HTTP_USER_AGENT")
Request.ServerVariables("REMOTE_ADDR")
Request.ServerVariables("HTTP_REFERER")
PHP, Server variables
$_SERVER["HTTP_HOST"]; 
$_SERVER["PHP_SELF"];
$_SERVER["HTTP_USER_AGENT"];
$_SERVER["REMOTE_ADDR"];
@$_SERVER["HTTP_REFERER"];
@ = ignore errors
ASP Page redirects
Response.redirect("wrong_link.htm")
PHP Page redirects
header("Location: wrong_link.htm");
ASP, GET and POST variables
Request.QueryString("chat")
Request.Form("username")
PHP, GET and POST variables
@$_GET["chat"];       @ = ignore errors
@$_POST["username"];
ASP, prevent page caching
Response.CacheControl="no-cache"
Response.AddHeader "pragma","no-cache"
PHP, prevent page caching
header("Cache-Control: no-store, no-cache");
header("Pragma: no-cache");
ASP, Limit script execution time, in seconds
Server.ScriptTimeout(240)
PHP, Limit script execution time, in seconds
set_time_limit(240);
ASP, Timing script execution
s_t=timer ...ASP script to be timed... 
duration=timer-s_t
response.write duration &" seconds"
PHP, Timing script execution
$s_t=microtime(); ...PHP script to be timed... 
$duration=microtime_diff($s_t,microtime());
$duration=sprintf("%0.3f",$duration);
echo $duration." seconds"; //required function
function microtime_diff($a,$b) {
list($a_dec,$a_sec)=explode(" ",$a);
list($b_dec,$b_sec)=explode(" ",$b);
return $b_sec-$a_sec+$b_dec-$a_dec;
}

File System Functions

ASP, create a file system object (second line is wrapped)
'Required for all file system functions
fileObj=Server.CreateObject
 ("Scripting.FileSystemObject")
PHP, create a file system object
Not necessary in PHP
ASP, check if a file exists
pFile="data.txt"
fileObj.FileExists(Server.MapPath(pFile))
PHP, check if a file exists
$pFile="data.txt";
file_exists($pFile);
ASP, Read a text file
pFile="data.txt" 
xPage=fileObj.GetFile(Server.MapPath(pFile))
xSize=xPage.Size 'Get size of file in bytes
xPage=fileObj.OpenTextFile(Server.MapPath(pFile))
temp=xPage.Read(xSize) 'Read file
linkPage.Close
PHP, Read a text file
$pFile="data.txt"; 
$temp=file_get_contents($pFile); //Read file

Time and Date Functions

ASP, Server Time or Date
Now, Date, Time
PHP, Server Time or Date
date()
ASP, Date format (default)
Now = 12/8/2007 11:29:27 AM
Date = 12/8/2007
Time = 11:29:27 AM

Various ASP functions extract date parts:

Month(Date) = 12
MonthName(Month(Date)) = December
Day(Date) = 8
WeekdayName(Weekday(Date)) = Saturday
WeekdayName(Weekday(Date),False) = Sat
PHP, Date format
There is no default format in PHP.
The date() function is formatted using codes:

date("n/j/Y g:i:s A") = 12/8/2007 11:29:27 AM

date("n") = 12
date("F") = December
date("j") = 8
date("l") = Saturday
date("D") = Sat

Numeric Functions

ASP, convert decimal to integer
Int()

n=Int(x)
PHP, convert decimal to integer
floor()

$n=floor($x);
ASP, determine if a value is numeric
IsNumeric()

if IsNumeric(n) then ...
PHP, determine if a value is numeric
is_numeric()

if (is_numeric($num)) {...}
ASP, modulus function
x mod y
PHP, modulus function
$x % $y



Links:


該文章在 2012/6/6 23:42:58 編輯過(guò)
相關(guān)文章
正在查詢...
點(diǎn)晴ERP是一款針對(duì)中小制造業(yè)的專業(yè)生產(chǎn)管理軟件系統(tǒng),系統(tǒng)成熟度和易用性得到了國(guó)內(nèi)大量中小企業(yè)的青睞。
點(diǎn)晴PMS碼頭管理系統(tǒng)主要針對(duì)港口碼頭集裝箱與散貨日常運(yùn)作、調(diào)度、堆場(chǎng)、車隊(duì)、財(cái)務(wù)費(fèi)用、相關(guān)報(bào)表等業(yè)務(wù)管理,結(jié)合碼頭的業(yè)務(wù)特點(diǎn),圍繞調(diào)度、堆場(chǎng)作業(yè)而開發(fā)的。集技術(shù)的先進(jìn)性、管理的有效性于一體,是物流碼頭及其他港口類企業(yè)的高效ERP管理信息系統(tǒng)。
點(diǎn)晴WMS倉(cāng)儲(chǔ)管理系統(tǒng)提供了貨物產(chǎn)品管理,銷售管理,采購(gòu)管理,倉(cāng)儲(chǔ)管理,倉(cāng)庫(kù)管理,保質(zhì)期管理,貨位管理,庫(kù)位管理,生產(chǎn)管理,WMS管理系統(tǒng),標(biāo)簽打印,條形碼,二維碼管理,批號(hào)管理軟件。
點(diǎn)晴免費(fèi)OA是一款軟件和通用服務(wù)都免費(fèi),不限功能、不限時(shí)間、不限用戶的免費(fèi)OA協(xié)同辦公管理系統(tǒng)。
Copyright 2010-2025 ClickSun All Rights Reserved

主站蜘蛛池模板: 国品一二三产区区 | 国产手机在线小视频 | 爱豆传媒免费播放 | 国产精彩亚洲中文 | 精品亚洲人 | 九九热在线观看官网 | 国产大片亚州一 | 国产美女自卫 | 日韩成人3D动漫 | 97视频观看 | 国产精品自拍视频 | 欧美一级大 | 国产夫妇精品自在线 | 午夜欧美一级电影 | 国产视频每日更新 | 国产欧美自拍视频 | 91精品福利在 | 午夜福利免费院 | 91免费视频在线看 | 日韩成人激情综合网 | 成人激情视| 片免费在线 | 欧美一级精品 | 国产尤物尤物在线看 | 国产亚洲精品在天 | 国产玉足榨精视频 | 国产精品福利社 | 蜜桃视频专区 | 国产视频线路一 | 91精品国产91 | 无码帝国www无码专 无码电影免费黄网站 | 成人日本一区二区 | 国产丝袜在线视频 | 国产九九在线视频 | 国产精品永久免费 | 欧美日韩国产第1 | 日韩午夜影视 | 国内自拍一区 | 91精品国产秘入口 | 欧美淫视频在线观看 | 国产亚洲成a |