close

Trust Me!! Trust You!!


  • Blog
  • Local Log
  • Tag Cloud
  • Key Log
  • Guestbook
  • RSS Feed
  • Write a Post
  • Admin

혹시 블로그 스킨이 깨져 보이시나요? 최신버전의 Internet Explorer(Windows용), Opera, Firefox를 사용해보세요.

ASP / PHP Cross Reference

웹 프로그래밍
2007/04/10 01:11
 

General syntax

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

not available?
PHP Comments, block
/*
  The quick brown fox
  jumped over the lazy dogs.
*/
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 = 3/19/2007 8:13:10 AM
Date = 3/19/2007
Time = 8:13:10 AM

Various ASP functions extract date parts:

Month(Date) = 3
MonthName(Month(Date)) = March
Day(Date) = 19
WeekdayName(Weekday(Date)) = Monday
WeekdayName(Weekday(Date),False) = Mon
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") = 3/19/2007 8:13:10 AM

date("n") = 3
date("F") = March
date("j") = 19
date("l") = Monday
date("D") = Mon

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
이올린에 북마크하기
No received trackback. / One comment was tagged.

Trackback Address :: http://viper150.cafe24.com/trackback/17

You can also say.

Prev 1 ... 279 280 281 282 283 284 285 286 287 ... 298 Next
블로그 이미지
이것저것 불펌금지도 퍼다가 담습니다. 외부에 비공개된 페이지 입니다. By. 어른왕자

카테고리

  • 전체 (298)
    • 사는 이야기 (115)
    • 웹 프로그래밍 (102)
    • App 프로그래밍 (22)
    • IT 뉴스&기타 (22)
    • 박한별 (4)
    • 역사&기타지식 (9)

태그목록

  • UTF-8
  • 최적화
  • 명품지갑
  • 방화벽
  • javascript
  • I Got A Boy
  • Billy Joel
  • preventDefault
  • java.util.Map
  • 의료민영화
  • C Left
  • 계산
  • CGI
  • security
  • C
  • FilePathCheckerModuleExample.dll
  • Filter
  • 우리
  • 바코드
  • 국가통계포털
  • CD케이스
  • 전업남편
  • 웃김
  • CentOS
  • gts650
  • mbc
  • 윈도우7
  • addFlashAttribute
  • pom.xml
  • 唐田

최근에 올라온 글

  • 보험사의 조정신청 대응방법.
  • 어느 천재의 앞선 시선.
  • [병맛더빙] 누구게..... (1)
  • 韓경제 `회색 코뿔소` 상황...
  • SVN Connector 설치 URL.
  • 군대를 가지 않는 서울대생.
  • “운은 하늘의 귀여움 받는...
  • 목장에서 알바하다가 캐스...
  • [펌]믿고 거르는 관상.
  • 하루에 1세트씩 하면 좋다...

최근에 달린 댓글

  • <p align="center"><a href="h... 라임애드 02/14
  • <div style="OVERFLOW: hidden... 고사니 02/12
  • <p align="center"><a href="h... 라임정보 02/07
  • <p><img src="https://i.imgur... 브레드 01/22
  • <p><img src="https://i.imgur... 브레드 01/22

최근에 받은 트랙백

  • read this post from Bookie 7. read this post from Bookie 7 02/28
  • công ty may đồng phục. công ty may đồng phục 01/08
  • Israelnightclub`s recent blo... Israelnightclub`s recent blo.. 01/06
  • Suggested Browsing. Suggested Browsing 01/06
  • similar site. similar site 01/06

글 보관함

  • 2019/03 (1)
  • 2018/12 (1)
  • 2018/09 (1)
  • 2018/08 (1)
  • 2018/02 (1)

달력

«   2021/03   »
일 월 화 수 목 금 토
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

링크

  • Total : 263574
  • Today : 31
  • Yesterday : 43
Tattertools
Eolin
rss

어른왕자's blog is powered byTattertools1.1.2.2 : Animato