asp php 对照表,asp与php常用函数对照表

asp(vbs)常用函数30个PHP类似函数

trim( )trim( )

replace( )str_replace( ) // str_ireplace( )

split( )explode( )

ubound( )count( )

isNull( )is_null( )

empty( )

0,””,Null,False,空属性对象都将返回false

isEmpty( )empty( ) 同上

isset( ) 是否已初始化

isNumeric( )is_numeric( )

instr( )

instrRev( )strpos( ) // stripos( )

strrpos( ) // strripos( )

mid( )substr( )

left( )

right( )无对应函数

len( )strlen( )

cint( )intval( )

cstr( )strval( )

now( ) 当前日期+时间

date( ) 当前日期

year( )

month( )

day( )date (“Y-m-d H:i:s”)

date(“Y-m-d”)

date(“Y”)

date(“m”)

date(“d”)

详细请参见补充8中日期函数表

timer( )microtime( )

datediff( )无对应内置函数,类似自定义函数如下

function DateDiff($date1,$date2,$unit="d"){

switch ($unit) {

case 's':

$dividend = 1;

break;

case 'i':

$dividend = 60;

break;

case 'h':

$dividend = 60*60;

break;

case 'd':

$dividend = 60*60*24;

break;

case 'm':

$dividend = 60*60*24*30;

break;

case 'y':

$dividend = 60*60*24*365;

break;

default:

$dividend = 60*60*24;

}

$time1 = strtotime($date1);

$time2 = strtotime($date2);

if ($time1 && $time2){

return ceil(($time1 - $time2) / $dividend);

}else{

return false;

}

}

使用:

echo DateDiff('2009-08-30 12:12:12','2009-08-23 12:50:22','h');

dateadd( )无对应内置函数,类似自定义函数如下

function DateAdd($date,$int,$unit="d"){

if(strpos($date," ")){

$temp=explode(" ",$date);

$dateArr1=explode("-",$temp[0]);

$dateArr2=explode(":",$temp[1]);

}else{

return "这不是一个标准的Y-m-d H:i:s格式日期";

}

$value[$unit]=$int;

$newDate=mktime($dateArr2[0]+$value['h'],$dateArr2[1]+$value['i'],$dateArr2[2]+$value['s'],$dateArr1[1]+$value['m'],$dateArr1[2]+$value['d'],$dateArr1[0]+$value['y']);

return date("Y-m-d H:i:s",$newDate);

}

使用:

echo now()."

".DateAdd(now(),30,"m");

rnd( )rand( )

int( )

round( )floor( )

round( )

lcase( )

ucase( )strtolower( )

strtoupper( )

asc( )

chr( )ord( )

chr( )

modfmod( )

request.form( )$_POST[ ]

request.queryString( )$_GET[ ]

response.write( )echo( )

print( )

response.redirect("../test.php")

response.redirect 可以至于页面任何地方,跳转之前不会再往下执行代码header("location: index.php");

header必须至于页面顶部,header跳转之前仍会执行下面的代码,需要加break; 才能打断执行

response.endexit( ) 终止当前所有程序

exit(1) 退出当前一层程序

request.cookies( )$_COOKIE[ ]

response.cookies( )setcookie

request.serverVariables( )$_SERVER[ ]

session( )$_SESSION[ ]

application( )无此概念

server.mapPath( )无此概念

server.HTMLEncode( )htmlspecialchars( )

server.URLEncode( )

asp中内置组件 scripting.fileSystemObjectPHP类似用法

FSO.createTextFilefopen(file,’w’)

FSO.openTextFilefopen(file,’r’)

readAllfread

writefwrite

FSO.deleteFileunlink

FSO.copyFilecopy

FSO.moveFilecopy && unlink

FSO.getFilefopen

FSO.fileExistsfile_exists is_file

FSO.deleteFolderrmdir

FSO.copyFolder无对应函数

//复制目录,将$dir_path目录里面的文件照原样复制到$target_dir,注意目录名应该相同,即需要创建目录

function copy_dir($dir_path,$target_path){

mkdir($target_path);

foreach (scandir($dir_path) as $file){

if($file=='.'||$file=='..')continue;

if(is_dir($dir_path.'/'.$file)) copy_dir($dir_path.'/'.$file,$target_path.'/'.$file);//递归

else

copy($dir_path.'/'.$file,$target_path.'/'.$file);

}

}

FSO.createFoldermkdir

FSO.getFolderopendir && readdir

FSO.folderExistsfile_exists is_dir

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值