Asp几秒钟后再执行后面的代码
作者:admin 日期:2012-04-10
Asp动态定义变量之将变量的值作为变量名
作者:admin 日期:2012-04-10
Asp过滤数组中的重复数据
作者:admin 日期:2012-04-10
'过滤数组中的重复数据
Function FilterRepeatDataFromArray(cxstr1,cxstr2)
IF isarray(cxstr1) Then
cxarraynull = "对不起,参数1不能为数组。"
Exit Function
End IF
IF cxstr1 = "" or isempty(cxstr1) Then
cxarraynull = "nodate"
Exit Function
End IF
ss = split(cxstr1,cxstr2)
cxs=cxstr2&ss(0)&cxstr2
sss=cxs
For m = 0 To ubound(ss)
cc = cxstr2&ss(m)&cxstr2
IF instr(sss,cc)=0 Then
sss = sss&ss(m)&cxstr2
End IF
Next
FilterRepeatDataFromArray = right(sss,len(sss)-len(cxstr2))
FilterRepeatDataFromArray = left(FilterRepeatDataFromArray,len(FilterRepeatDataFromArray)-len(cxstr2))
End Function
asp获取GMT时间
作者:admin 日期:2012-04-10
<%
Function DateTimeToGMT(sDate)
Dim dWeek,dMonth
Dim strZero,strZone
strZero="00"
strZone="GMT"
dWeek=Array("Sun","Mon","Tue","Wes","Thu","Fri","Sat")
dMonth=Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
DateTimeToGMT = dWeek(WeekDay(sDate)-1)&", "&Right(strZero&Day(sDate),2)&" "&dMonth(Month(sDate)-1)&" "&Year(sDate)&" "&Right(strZero&Hour(sDate),2)&":"&Right(strZero&Minute(sDate),2)&":"&Right(strZero&Second(sDate),2)&" "&strZone
End Function
Response.Write( DateTimeToGMT( Now() ) )
%>
ASP获取文件的最后修改时间
作者:admin 日期:2012-04-10
php类继承实例
作者:admin 日期:2012-04-10
- <?php
- class Person
- {
- public $name, $age, $sex;
- public function __construct($name, $age, $sex)
- {
- $this->name = $name;
- $this->age = $age;
- $this->sex = $sex;
- }
- }
- class Child extends Person
- {
- public function say($word)
- {
- echo($word);
- }
- }
- $Child = new Child("田志刚", 30, "男");
- $Child->say("hello");
- echo($Child->name);
- //输出结果:hello田志刚
- ?>
PHP htmlentities和html_entity_decode
作者:admin 日期:2012-04-10
php javascript cookie中文乱码解决办法
作者:admin 日期:2012-04-10
至于此类情况可以在服务端对中文进行处理。
php类似于javascript encodeURI和decodeURI解码的方法(转)
<script language="javascript">
var a = encodeURI("电影");
alert(a);
var b = decodeURI(a);
alert(b)
</script>
<?php
$a = urlencode(iconv("gb2312", "UTF-8", "电影")); //等同于javascript encodeURI("电影");
echo $a;
$b = iconv("utf-8","gb2312",urldecode("%E7%94%B5%E5%BD%B1")); //等同于javascript decodeURI("%E7%94%B5%E5%BD%B1");
echo $b;
?>
如果编码是UTF-8的话就可以直接用urlencode 或 urldecode 转换!
如果不行可以转换两次就可以了,即在JS里面用2次decodeURI。
php、asp以“流格式”下载服务器端文件
作者:admin 日期:2012-04-10
解决WORD,EXCEL,TXT,图片等文件类型直接在IE中被打开的问题
- <%
- Function downFileFromServer(showFileName, downFilePath)
- response.Clear
- response.Buffer = true
- Set ads = Server.CreateObject("ADODB.Stream")
- ads.Type = 1
- ads.Mode = 3
- ads.Open
- ads.LoadFromFile downFilePath
- response.AddHeader("Content-Encoding", "None")
- response.AddHeader("Cache-Control", "Private")
- response.AddHeader("Content-Length", ads.Size)
- response.AddHeader("Content-Disposition", "attachment; filename=" & showFileName)
- response.ContentType = "application/octet-stream"
- response.BinaryWrite(ads.Read(ads.Size))
- ads.Close
- Set ads = nothing
- response.Flush
- response.End
- End Function
- Call downFileFromServer("abc.test", Server.MapPath("test.asp"))
- %>
- <?php
- function downFileFromServer($showFileName, $downFilePath)
- {
- if(file_exists($downFilePath))
- {
- if(is_readable($downFilePath))
- {
- if(Trim($showFileName) == '')
- {
- $showFileName = 'undefined';
- }
- ob_start();
- ob_clean();
- $file_size = filesize($downFilePath);
- header('Content-Encoding:none');
- header('Cache-Control:private');
- header('Content-Length:' . $file_size);
- header('Content-Disposition:attachment; filename=' . $showFileName);
- header('Content-Type:application/octet-stream');
- readfile($downFilePath);
- ob_flush();
- }
- }
- }
- //Sample
- downFileFromServer('a.abc', 'test.php');
- ?>
php遍历文件夹和文件
作者:admin 日期:2012-04-10
<?php
$path = 'UploadFile';
function getfiles($path)
{
if(!is_dir($path))
{
return;
}
$handle = opendir($path);
while( false !== ( $f = readdir( $handle ) ) )
{
if($f != '.' && $f != '..')
{
$path2 = $path . '/' . $f;
if( is_dir( $path2 ) )
{
echo "<br />" . $f;
getfiles( $path2 );
}
else
{
echo "<br />" . $f;
}
}
}
}
print_r( getfiles($path) );
?>
PHP中的escape函数以及Jsonp实例
作者:admin 日期:2012-04-10
function phpescape($str){
preg_match_all("/[\x80-\xff].|[\x01-\x7f]+/",$str,$newstr);
$ar = $newstr[0];
foreach($ar as $k=>$v){
if(ord($ar[$k])>=127){
$tmpString=bin2hex(iconv("GBK","ucs-2",$v));
if (!eregi("WIN",PHP_OS)){
$tmpString = substr($tmpString,2,2).substr($tmpString,0,2);
}
$reString.="%u".$tmpString;
} else {
$reString.= rawurlencode($v);
}
}
return $reString;
}
实例:
$xml = file_get_contents("index.xml");
$xml = phpescape($xml);
$jsondata = "{symbol:\"" . $xml . "\"}";
echo $_GET['callback'].'('.$jsondata.')';
PHP伪原创之随机段落
作者:admin 日期:2012-04-10
<?php
//原始字符串
$p = "<p>p0</p><p>p1</p><p>p2</p><p>p3</p>";
//处理完之后的字符串
$p = DoP($p);
//输出处理的结果
echo($p);
/*处理P标记**/
function DoP($content)
{
//正则提取P标记
$arr = GetField($content);
//将每个P标记都加上ID
$arrLen = count($arr);
for ( $i = 0; $i < $arrLen; $i ++ )
{
$arr[$i] = str_replace("<p", "<p id=\"p" . $i . "\"", $arr[$i]);
}
//对数组重新排序
shuffle($arr, SORT_NUMERIC);
//将数组组成字符串
$content = implode("", $arr);
return ($content);
}
/*正则表达式提取**/
function GetField($content)
{
$patrn = "/<p[\s\S]*?>[\s\S]*?<\/p>/i";
preg_match_all($patrn, $content, $matches);
return($matches[0]);
}
?>
广告位