php文本计数器的完整代码。
<?
/**
* 简单的文本计数器
* by www.
* date 2013/3/22
*/
$memo_file="count/vst.txt";
if ($phpxcount<>$REMOTE_ADDR){
$visits = file($memo_file);
$number_of_last_visit = $visits[0];
$number_of_new_visit = ++$number_of_last_visit;
$fp = fopen($memo_file, "w");
$fw = fwrite($fp, $number_of_new_visit);
fclose($fp);
$len_str = strlen($number_of_new_visit);
for($i=(0);$i<$len_str;$i++){
$numbers_explode()d = substr($number_of_new_visit,$i,1);
$output_str = $output_str . "<img src="/blog_article/$numbers_exploded.gif">";
}
}else{
$visits = file($memo_file);
$number_of_last_visit = $visits[0];
$number_of_new_visit = $number_of_last_visit;
$fp = fopen($memo_file, "w");
$fw = fwrite($fp, $number_of_new_visit);
fclose($fp);
$len_str = strlen($number_of_new_visit);
for($i=(0);$i<$len_str;$i++){
$numbers_exploded = substr($number_of_new_visit,$i,1);
$output_str = $output_str . "<img src="/blog_article/$numbers_exploded.gif">";
}
}
echo $output_str;
?>
您可能感兴趣的文章:
php计数器的简单例子
php 计数器(文本、图形计数器)代码
php mysql计数器的简单实现
转换字符串的网址为超级链接。
<?php
//字符串 网址 转为超链接
$string = "连接http://www. 站点";
//连接后需要有个空格或回车。
$string = eregi_replace("http://([^ ,\r\n]*)","<a href=\\0 target=_blank>\\0</a>",$string);
$string = eregi_replace("ftp://([^ ,\r\n]*)","<a href=\\0 target=_blank>\\0</a>",$string);
echo $string;
?>
文本数据记录类似下面这样:
aaa,bbb,ccc,ddd,eee
fff,ggg,hhh,iii,jjj,kkk
以","符号分隔每一行中的记录。
处理程序,load_txt_to_data.php
//导入文本数据
//by www.
$hostname="localhost";
$username="yourname";
$password="yourpwd";
$dbname="yourdb";
mysql_connect()($hostname,$username,$password);
mysql_select_db("$dbname");
$mydate=file("demo.txt");
$n=count($mydate);
for($i=0;$i<$n;$i++){
$date=explode()(",",$mydate[$i]);
$str="insert into ip values('$date[0]','$date[1]','$date[2]','$date[3]','$date[4]')";//
mysql_query()($str);
}
mysql_close();
echo "ok!";
?>