如果你的空间只支持PHP的话,你吧ASP代码传上去是不能正常运行的.
对于数据库来说,ASP和PHP都只是使用数据库,他们本身并不是数据库.在网上看到PHP一样可以连ACCESS数据库,而ASP也一样可以使用MYSQL数据库.
不过我按照那些方法实验一直没有成功过,不知道是何原因.
这个问题还真不知道.不过为了帮助你,在网上找了一个参考资料希望适合你: 用Microsoft.XMLHTTP调用本地PHP文件runphp.php,并向runphp.php提交要执行的php代码
当然,在runphp.php 中要用到eval()来执行提交的代码;相当简单吧
具体细节实现:
①用Microsoft.XMLHTTP调用本地PHP
程序代码 function runphp(command)
on error resume next
dim Http
dim serPhp
serPhp="http://" Request.ServerVariables("SERVER_NAME") mid(Request.ServerVariables("PATH_INFO"),1,instrrev(Request.ServerVariables("PATH_INFO"),"/")) "runphp.php"
command=URLEncoding("phpcommand=" command)
set Http=server.createobject("Microsoft.XMLHTTP")
Http.open "POST",serPhp,false
Http.setrequestheader "content-length",len(command)
Http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
Http.send command
exit function
end if
set http=nothing
if err.number0 then err.Clear
end function
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
在提交的命令中,我们用的是post方法,会被urlencoded,那些",',\,还有中文.会在eval中执行错误,所以还需要进行处理,下面是编码处理函数:
程序代码 Function URLEncoding(vstrIn)
strReturn = ""
For i = 1 To Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) HFF Then
strReturn = strReturn ThisChr
Else
innerCode = Asc(ThisChr)
If innerCode 0 Then
innerCode = innerCode ◆ H10000
End If
Next
URLEncoding = strReturn
下面是runphp.php文件内容:比较简单
程序代码 ?
if($_SERVER["HTTP_HOST"]==$_SERVER["SERVER_NAME"]){
$phpCommand=StripSlashes($_POST["phpcommand"]);
if(trim($phpCommand)!="")eval($phpCommand);
}
第一句 if($_SERVER["HTTP_HOST"]==$_SERVER["SERVER_NAME"])是为了限至命令只能从本地服务器提交,有一定的安全措施
以上就是土嘎嘎小编为大家整理的asp接收php数据类型相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!