ASP中文件的写入最简单代码

2009年4月19日

set fso = Server.CreateObject(“Scripting.FileSystemObject”) ‘fso对象
set htmlwrite = fso.CreateTextFile(server.mappath(“text.txt”))
htmlwrite.write “这是写入的内容”
htmlwrite.close
set fso=nothing

admin asp ,

ASP读取文件流的自定义方法

2009年4月19日

Function fso_file_open(fso_file_open_name)
on error resume next
if fso_file_open_name<>“” then
Set lq_fso=Server.Createobject(“Scripting.FilesystemObject”)
if lq_fso.FileExists(“”&Server.MapPath(“”&fso_file_open_name&”")&”") then
Set lq_read = lq_fso.OpenTextFile(“”&Server.MapPath(“”&fso_file_open_name&”")&”",1,True)
fso_file_open=lq_read.ReadAll
lq_read.Close
else
fso_file_open=”"
end if
Set lq_fso=Nothing
else
fso_file_open=”"
end if
End Function

admin asp

jmail的组件在ASP中应用

2009年4月19日

<%
dim body
body="test” ‘定义邮件内容
Set msg = Server.CreateObject(“JMail.Message”)
msg.ContentType = “text/html” ‘定义邮件格式为文本还是超文本
msg.Priority = 1 ‘优先级
msg.silent = true
msg.Logging = true
msg.Charset = “gb2312″ ‘编码
msg.MailServerUserName = “test@7dit.com” ‘输入smtp服务器验证登陆名 (邮局中任何一个用户的Email地址)
msg.MailServerPassword = “test” ‘输入smtp服务器验证密码 (用户Email帐号对应的密码)
msg.From = “test@7dit.com” ‘发件人Email
msg.FromName = “奇点” ‘发件人姓名
msg.AddRecipient “rec@7dit.com” ‘收件人Email
msg.Subject = “test” ‘信件主题
msg.Body = body
msg.Send (“mail.test.com”) ‘smtp服务器地址(企业邮局地址)
set msg = nothing
%>

admin asp ,

ASP实用的两个正则函数

2009年4月19日

< %

function shownew(str,patrn,strRepl)
Dim regEx
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Global = True
regEx.Pattern = patrn
shownew = regEx.Replace(str, strRepl)
end function
Response.write shownew("12345sdf32","(\d+)","$1″)
‘ 函数用于替换指定的字符串
%>

阅读全文…

admin asp ,

php解析escape

2009年4月19日

php如何直接解码javascript中的escape函数加码后的内容?
使用:
$result = uniDecode($str,’gb2312′);
代码:
function uniDecode($str,$charcode=”") {
$text = preg_replace_callback(“/%u[0-9A-Za-z]{4}/”,”toUtf8″,$str);
if (empty($charcode)) {
return $text;
} else {
return mb_convert_encoding($text, $charcode, ‘utf-8′);
}
} 阅读全文…

admin php ,

获取浏览器具体类型的自定义方法

2009年4月19日

function browse_info() //获取浏览器具体类型的自定义方法
{
$browser=”";$browserver=”";
$Browsers =array(“Lynx”,”MOSAIC”,”AOL”,”Opera”,”JAVA”,”MacWeb”,”WebExplorer”,”OmniWeb”);
$Agent = $GLOBALS["HTTP_USER_AGENT"];
for ($i=0; $i< =7; $i++)
{
if (strpos($Agent,$Browsers[$i]))
{
$browser = $Browsers[$i];
$browserver ="";
}
}
if (ereg("Mozilla",$Agent) && !ereg("MSIE",$Agent))
{
$temp =explode("(", $Agent); $Part=$temp[0];
$temp =explode("/", $Part); $browserver=$temp[1];
$temp =explode(" ",$browserver); $browserver=$temp[0];
$browserver =preg_replace("/([d.]+)/","1",$browserver);
$browserver = " $browserver";
$browser = "Netscape Navigator";
}
阅读全文…

admin php

utf-8字符串截取的PHP代码

2009年4月19日

function utf_substr($str,$len)
{
for($i=0;$i< $len;$i++)
{
$temp_str=substr($str,0,1);
if(ord($temp_str) > 127)
//截取字符串第一字符的ascii码是否大于127,0-127的128个ASCII码代表了字母数字即一些标点符号等,超过此范围则为需要以unicode码显示
{
$i++;
if($i< $len)
{
$new_str[]=substr($str,0,3); //unicode中汉字占三个位,截取三位表示截取一个汉字
$str=substr($str,3);
}
}
else
{
$new_str[]=substr($str,0,1);
$str=substr($str,1);
}
}
return join($new_str);
}
阅读全文…

admin php

PHP邮件功能

2009年4月19日

< ?php
//例子
if(send_mail('aene369@126.com','发信标题11','发信内容11')=="")
{
echo "发送成功!
“;
} else{
echo “发送失败!
“;
}
/*$url = “http://mail.163.com”;
$url2 = “http://mail.126.com”;
$lines_array = file($url);
$lines_string = implode(”, $lines_array);
eregi(“(.*)”, $lines_string, $head);
echo $head[0];
echo $head[1];
echo $head[2];*/
阅读全文…

admin php ,

C#执行存储过程的方法

2009年4月19日

RoomInfo为一个实体类,因其中的一个属性为Byte数组,而相应的sql数据库中的列为Image类型,为了能插入数据,需要调用已定义的存储过程,INSERTROOMINFO为过程名。

存储过程:

阅读全文…

admin C#

TP框架的分页类

2009年4月19日


ThinkPHP内置了分页类,可以简单的进行分页数据显示,下面是例子分析

程序代码

阅读全文...

admin php , ,