asp仿php的一些函式分享

2022-09-21 09:39:11 字數 3771 閱讀 4369

複製** **如下:

'過程:輸出字串[代替response.write]

sub echo(str)

response.write(str)

end sub

'函式:獲取表單[代替request.form]

function reqf(str)

reqf = request.form(str)

end function

'過程:結束頁面並輸出字串

sub die(str)

response.write(str)

response.end()

end sub

'函式:將asp檔案執行結果返回為字串

function ob_get_contents(path)

dim tmp, a, b, t, matches, m

dim str

str = file_iread(path)

tmp = "dim htm : htm = """""&vbcrlf

a = 1

b = instr(a, str, "while b > a + 1

t = mid(str, a, b - a -2)

t = replace(t, vbcrlf, "")

t = replace(t, vbcr, "")

t = replace(t, """", """""")

tmp = tmp & "htm = htm & """ & t & """" & vbcrlf

a = instr(b, str, "%\>") + 2

tmp = tmp & str_replace("^\s*=", mid(str, b, a - b -2), "htm = htm & ") & vbcrlf

b = instr(a, str, "wend

t = mid(str, a)

t = replace(t, vbcrlf, "")

t = replace(t, vbcr, "")

t = replace(t, """", """""")

tmp = tmp & "htm = htm & """ & t & """" & vbcrlf

tmp = replace(tmp, "response.write", "htm = htm & ", 1, -1, 1)

tmp = replace(tmp, "echo", "htm = htm & ", 1, -1, 1)

'execute(tmp)

executeglobal(tmp)

htm = replace(htm, "", vbcrlf)

htm = replace(htm, "", vbcr)

ob_get_contents = htm

end function

'過程:動態包含檔案

sub include(path)

echo ob_get_contents(path)

end sub

'函式:base64加密

function base64encode(byval str)

if isnull(str) then exit function

dim base64

set base64 = new base64_class

str = base64.encode(str)

set base64 = nothing

base64encode = str

end function

'函式:base64解密

function base64decode(byval str) 程式設計客棧

if isnull(str) then exit function

dim base64

set base64 = new base64_class

str = base64.decode(str)

set base64 = nothing

base64decode = str

end function

'函式:url加密

function urlencode(byval str)

if isnull(str) then exit function

str = server.urlencode(str)

urlencode = str

end funwww.cppcns.comction

'函式:escape加密

function escape(byval str)

if isnull(str) then exit function

dim i, c, a, tmp

tmp = ""

for i = 1 to len(str)

c = mid(str, i, 1)

a = ascw(c)

if (a>= 48 and a<= 57) or (a>= 65 and a<= 90) or (a>= 97 and a<= 122) then

tmp = tmp & c

elseif instr("@*_+-./", c) > 0 then

tmp = tmp & c

elseif a>0 and a<16 then

tmp = tmp & "%0" & hex(a)

elseif a>= 16 and a<256 then

tmp = tmp & "%" & hex(a)

else

tmp = tmp & "%u" & hex(a)

end if

next

escape = tmp

end function

'函式:escape解密

function unescape(byval str)

if isnull(str) then exit fwww.cppcns.comunction

dim i, c, tmp

tmp = ""

for i = 1 to len(str)

c = mid(str, i, 1)

if mid(str, i, 2) = "%u" and i<= len(str) -5 then

if isnumeric("&h" & mid(str, i + 2, 4)) then

tmp = tmp & chrw(cint("&h" & mid(str, i + 2, 4)))

i = i + 5

else

tmp = tmp & c

enwww.cppcns.comd if

elseif c = "%" and i<= len(str) -2 then

if isnumeric("&h" & mid(str, i + 1, 2)) then

tmp = tmp & chrw(cint("&h" & mid(str, i + 1, 2)))

i = i + 2

else

tmp = tmp & c

end if

else

tmp = tmp & c

end if

next

unwww.cppcns.comescape = tmp

end function

本文標題: asp仿php的一些函式分享

本文位址:

一些asp時間函式

在做網頁時,經常要用到的日期函式和時間函式,但是,對於asp新手來說,這些函式的引數和用法比較複雜,所以本站 jeali.com 特將這些函式的用法和引數歸納一下,以備查閱,同時也希望對asp新手有所幫助。一 日期函式 date 函式,此函式功能是獲取當前日期,注意,這裡獲取的日期是網頁所在伺服器的...

php一些函式

1.show source 函式是php中的內建函式,用於返回突出顯示php語法的檔案。通過使用html標記突出顯示語法 2.strstr 函式 定義和用法 strstr 函式搜尋字串在另一字串中是否存在,如果是,返回該字串及剩餘部分,否則返回 false。注釋 該函式是二進位制安全的。注釋 該函式...

一些常用的php函式

這是一些使用頻率比較高的函式,有的來自別人的程式.1.產生隨機字串函式 function random length return hash 2.擷取一定長度的字串 注 該函式對gb2312使用有效 function wordscut string,length sss 0 for i 0 i le...