一段asp转php

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。 http://blog.csdn.net/mayongzhan - 马永占,myz,mayongzhan

程序是共通的...
下面是asp转php的代码
虽然有的地方不太清楚.基本上还是可以看出.任何语言都是可以互相转换的.
上面是php下面是asp
<?php
//-------------------------------------------------------------------------------------
class clsThief
{
//__________________
private $value_;
private $src_;
private $isGet_;
public function setSrc($str)
{
$this->src_ = $str;
}
public function getSrc()
{
return $this->src_;
}
public function getValue()
{
return $this->value_;
}
public function getVersion()
{
return "Version 2005";
}
function __construct()
{
$this->value_ = "";
$this->$src_ = "";
$this->isGet_ = false;
}
function __construct()
{
//construct
}
public function bytesToBstr($body,$cset)
{
$objstream = new Server.CreateObject("adodb.stream");//这个地方是什么...流?
$objstream->Type = 1;
//...
$text = $objstream->ReadText;//这里是要返回???
$objstream->Close;
$objstream = null;
}
public function steal()
{
if ($this->src_ == "") {
$http = new server.createobject("MSXML2.XMLHTTP");//这里是xml??
$http->open ;//...
//...
if ($http->readystate!=4) {
exit();//这里是中指执行
}
$this->value_ = $this->bytesToBstr(Http.responseBody,"GB2312");
$this->isGet_ = true;
$http = null;
if ($err->nulber!=0) { //这个应该不对
$err->Clear;
}
else {
echo "<script language='javascript'>alert('请先设置src属性!');</script>";
}
}
}
public function change($oldStr,$str)
{
if ($this->isGet_ = false) {
$this->steal();
$this->value_ = str_replace($this->value_,$oldStr,$str);//这里用的是php的函数
}
}
public function cutX($head,$bot)
{
if ($this->isGet_ = false) {
$this->steal();
if (strstr($this->value_, $head) && strstr($this->value_,$bot)) {//在$this->value中寻找$head ,找到返回true
$this->value_ = false;//这里是什么....
}
else {
$this->value_ = "<p align='center'>单词不存在</p>";
}
}
}
}
?>
<html><head>
<?php $wd=$_REQUEST['word'];
$myThief=new clsThief;
$myThief->src = "http://www.baidu.com/baidu?ie=gb2312&bs=&sr=&z=&ct=1048576&cl=3&f=8&word=".wd;
$myThief->steal;
$myThief->cutX("<ol>","</ol>");//这里是什么
$myThief->change("src='IMAGES/","src='http://www.baidu.com/IMAGES/");
$myThief->change("<br>以上结果由 <a href='http://www.dreye.com.cn' target='_blank'>Dr.eye译典通字典</a> 提供","");
$page = $myThief->value;
$myThief=null;
$page="".page."";//这个有什么意义...
?>
<title><?php echo $wd;?>解释</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><style type="text/css">
td,body{font-size:14.8px;color:#000}a:link{color:#000066;text-decoration:none}a:visited{COLOR:#000066;
TEXT-DECORATION:none}a:active{color:red;text-decoration:none}a:hover{color:green;text-decoration:underline}
.unnamed1 { font-size: 9pt; line-height: 20px}
.font12_bold{
font-size:12px;
color:#000000;
font-weight:bold;
}
</style>
<style type="text/css">
.ptitle {margin-top:3px; font-weight:bold}
.pcixin {margin - top : 3px; color = #FF0000}
.pexplain {margin-top:3px; margin-left:20px}
.pnewword {margin-top:3px; margin-right:10px; font-size:12; color:#9d0006; font-weight:bold}
.peng {margin-top:3px; margin-left:40px; font-size:16; color:#0000A0; font-weight:bold}
.pchi {margin-top:3px; margin-left:40px; font-size:16; color:#800040}
font.engi {color:#FF00FF; font-style:italic}
font.chinese {font-weight:normal; font-size:24; color:#008080}
#ft{clear:both;line-height:20px;background:#E6E6E6;text-align:center}
#ft,#ft *{color:#77C;font-size:12px;"" align=left> #ft span{color:#666}
.sb{height:2em;width:5.6em;font-size:14px;}
.kw{font-size:16px;height:1.78em;padding-top:2px;}</style></head>
<body><div align="center">
<p><a href=""><font color="#FF0000" size="+1"><strong>英汉词典</strong></font></a></p>
</div>
<br>
<table width="770" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="4"><div align="center">
<form name="f1" action="index.asp">
<input name="word" type="text" id="word" class=kw>
<input type=submit value=词典搜索 class=sb></form>
</div></td>
</tr>
<tr>
<td height="30" colspan="4">
<div align="center"><font color="green" size="3"><strong><?php echo $wd;?> 的解释</strong></font></div></td>
</tr>
</table>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="bm81">
<tr>
<td><?php echo $page;?>/td>
</tr>
</table>
</body></html>
-------------------------------------------
-------------------------------------------
-----------MyZ的分割线-------------
-------------------------------------------
<%
'-------------------------------------------------------------------------------------
Class clsThief
'____________________
Private value_ '
Private src_ '
Private isGet_ '
public property let src(str) '
src_=str
end property
public property get value '
value=value_
end property
Public Property get Version
Version="Version 2005"
End Property
private sub class_initialize()
value_=""
src_=""
isGet_= false
end sub
private sub class_terminate()
end sub
private Function BytesToBstr(body,Cset) '
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
public sub steal() '
if src_<>"" then
dim Http
set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",src_ ,false
Http.send()
if Http.readystate<>4 then
exit sub
end if
value_=BytesToBSTR(Http.responseBody,"GB2312")
isGet_= True
set http=nothing
if err.number<>0 then err.Clear
else
response.Write("<script>alert(""请先设置src属性!"")</script>")
end if
end sub
public sub change(oldStr,str)
if isGet_= false then call steal()
value_=replace(value_ , oldStr,str)
end sub
public sub cutX(head,bot)
if isGet_= false then call steal()
if instr(value_,head)>0 and instr(value_,bot)>0 then
value_=mid(value_ ,instr(value_ ,head),instr(value_ ,bot)-instr(value_ ,head)+len(bot))
else
value_= "<p align=""center"">单词不存在"
end if
end sub
end class
%>
<html><head>
<%wd=request("word")
dim myThief,page
set myThief=new clsThief
myThief.src="http://www.baidu.com/baidu?ie=gb2312&bs=&sr=&z=&ct=1048576&cl=3&f=8&word="&wd&""
myThief.steal
myThief.cutX "<ol>","</ol>"
myThief.change "src=""IMAGES/","src=""http://www.baidu.com/IMAGES/"
myThief.change "<br>以上结果由 <a href=""http://www.dreye.com.cn"" target=_blank>Dr.eye译典通字典</a> 提供",""
page=myThief.value
set myThief=nothing
page=""&page&""
%>
<title><%=wd%>解释</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><style type="text/css">
td,body{font-size:14.8px;color:#000}a:link{color:#000066;text-decoration:none}a:visited{COLOR:#000066;
TEXT-DECORATION:none}a:active{color:red;text-decoration:none}a:hover{color:green;text-decoration:underline}
.unnamed1 { font-size: 9pt; line-height: 20px}
.font12_bold{
font-size:12px;
color:#000000;
font-weight:bold;
}
</style>
<style type="text/css">
.ptitle {margin-top:3px; font-weight:bold}
.pcixin {margin - top : 3px; color = #FF0000}
.pexplain {margin-top:3px; margin-left:20px}
.pnewword {margin-top:3px; margin-right:10px; font-size:12; color:#9d0006; font-weight:bold}
.peng {margin-top:3px; margin-left:40px; font-size:16; color:#0000A0; font-weight:bold}
.pchi {margin-top:3px; margin-left:40px; font-size:16; color:#800040}
font.engi {color:#FF00FF; font-style:italic}
font.chinese {font-weight:normal; font-size:24; color:#008080}
#ft{clear:both;line-height:20px;background:#E6E6E6;text-align:center}
#ft,#ft *{color:#77C;font-size:12px;"" align=left> #ft span{color:#666}
.sb{height:2em;width:5.6em;font-size:14px;}
.kw{font-size:16px;height:1.78em;padding-top:2px;}</style></head>
<body><div align="center">
<p><a href=""><font color="#FF0000" size="+1"><strong>英汉词典</strong></font></a></p>
</div>
<br>
<table width="770" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="4"><div align="center">
<form name="f1" action="index.asp">
<input name="word" type="text" id="word" class=kw>
<input type=submit value=词典搜索 class=sb></form>
</div></td>
</tr>
<tr>
<td height="30" colspan="4">
<div align="center"><font color="green" size="3"><strong><%=wd%> 的解释</strong></font></div></td>
</tr>
</table>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="bm81">
<tr>
<td><%response.write(page) %></td>
</tr>
</table>
</body></html>
很对不住了.能改的我都改了...其他的忘了很多...有些不熟.....
by mayongzhan
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值