发新话题
打印

代码有错误,请大家帮忙看一下哪出问题了

代码有错误,请大家帮忙看一下哪出问题了

[Copy to clipboard]
PHP CODE:
class a
{
static protected 
$c;
protected 
$a;
protected 
$b;
private 
__construct($a="ds",$b="dsaf")
    {
$this->a=$a;
$this->b=$b;
}
static function 
type($m)
    {
    switch(
$m)
        {
        case 
1:
    if(
self::$a=NULL)
    
self::$a=new a($a,$b);
    break;
    case 
2:
        if(
self::$a=NULL)
   
self::$a=new a($a,$b);
    break;
    default:
        
self::$a=false;
    }
}
function 
xianshi()
    {
return 
$this->a;
}
}
$a=self::type(1);
$b=$a->xianshi();
echo 
$b;
Parse errorsyntax errorunexpected T_STRINGexpecting T_VARIABLE in D:appservwwwjingfeijingfeiexam12.php on line 14

TOP

似乎你没有实例化吧  temp_var = new a


我说错了,你用self::了 我不知道哪错了.......

[ 本帖最后由 极品黑公子 于 2008-4-17 16:31 编辑 ]
学会怎么调试程序,学会怎么设计模式,学会怎么配置环境,学会怎么带项目,学会怎么分析客户需求

TOP

[Copy to clipboard]
PHP CODE:
class a
{
static protected 
$c;
protected 
$a;
protected 
$b;
private function 
__construct($a="ds",$b="dsaf")
 {
$this->a=$a;
$this->b=$b;
}
static function 
type($m)
 {
 switch(
$m)
  {
  case 
1:
 if(
self::$c==NULL)
 
self::$c=new a();
 break;
 case 
2:
  if(
self::$c==NULL)
   
self::$c=new a();
 break;
 default:
  
self::$c=false;
 }
return 
self::$c;
}
function 
xianshi()
 {
echo 
"hello";
}
}
$a=a::type(1);
$b=$a->xianshi();
错误太多了,偶已经改好了

TOP

发新话题