用法
<?
include(“counter.php(做為現在的主流開發語言)“);
Counter(__FILE__);//為文件增加一個計數
if($php(做為現在的主流開發語言)_SELF==”/index.php(做為現在的主流開發語言)“)
{
$count=Counter(“INDEX_COUNT”);//為首頁增加一個計數
}
else
{
$count=Counter(“INDEX_COUNT”,””,0);//取得首頁計數
}
echo “你是第$count個訪問者”;
?>
——–counter.php(做為現在的主流開發語言)———–
<?
if(!isset($php(做為現在的主流開發語言)_INCLUDE_COUNTER_php(做為現在的主流開發語言)))
{$php(做為現在的主流開發語言)_INCLUDE_COUNTER_php(做為現在的主流開發語言)=__FILE;
$counter_error_state=0;
$counter_error_msg=””;
function Counter($file,$query=””,$add=1)
{
$db_name=”database”;
$db_user=”username”;
$db_pass=”password”;
$db_table=”counter”;
if(empty($file))
{
$counter_error_state=-100;
$counter_error_msg=”缺少第一個參數或參數為空”;
return -100;
}
global $php(做為現在的主流開發語言)_SELF,$QUERY_STRING,$counter_error_state,$counter_error_msg;
if(empty($db_user)||!$db_user||$db_user==””)$res=@MySQL(和PHP搭配之最佳組合)_connect(“localhost”);
else $res=@MySQL(和PHP搭配之最佳組合)_connect(“localhost”,$db_user,$db_pass);
if(!$res)
{
$counter_error_states=-10;
$counter_error_msg=”不能連接數據庫”;
return -10;
}
if(!@MySQL(和PHP搭配之最佳組合)_select_db($db_name))
{
$counter_error_states=-11;
$counter_error_msg=”不能選擇數據庫”;
return -11;
}
else
{
if(!$db_res=@MySQL(和PHP搭配之最佳組合)_query(“SELECT * FROM “.$db_table))
{