php面向对象编程中计数器类
求错!!!<?phpsession_start();classcounter{private$filename;publicfunction__construct($x)...
求错!!!
<?php
session_start();
class counter{
private $filename;
public function __construct($x){
$this->filename=$x;
}
public function getcoun(){
$countfile=$this->filename;
$fp=fopen($countfile,"r");
$num=fgets($fp,10);
if($_SESSION["count_id"]==""){
$num+=1;
$_SESSION["count_id"]="count_id";
}
$imagenum=intval($num);
for($i=0;$i<strlen($imagenum);$i++){
echo "0";
}
for($i=0;$i<strlen($imagenum);$i++){
echo "1";
}
$fp1=fopen($countfile,"w");
fputs($fp1,$num);
}
}
$conn=new counter("\count.txt");
echo "您是第";
$conn->getcoun();
echo "位访客";
?> 展开
<?php
session_start();
class counter{
private $filename;
public function __construct($x){
$this->filename=$x;
}
public function getcoun(){
$countfile=$this->filename;
$fp=fopen($countfile,"r");
$num=fgets($fp,10);
if($_SESSION["count_id"]==""){
$num+=1;
$_SESSION["count_id"]="count_id";
}
$imagenum=intval($num);
for($i=0;$i<strlen($imagenum);$i++){
echo "0";
}
for($i=0;$i<strlen($imagenum);$i++){
echo "1";
}
$fp1=fopen($countfile,"w");
fputs($fp1,$num);
}
}
$conn=new counter("\count.txt");
echo "您是第";
$conn->getcoun();
echo "位访客";
?> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询