2012-08-08 166 views
-2

有没有人知道我的代码为什么不起作用,我试着运行它,但它不起作用,当我把它放到网上时它说该页面无法加载。有什么我需要添加或什么?由于某些原因,我无法使其工作。为什么我的课不会工作?

class Network { 
    public $LastLocate = 0; 
    public $LastLocate2 = 0; 
    public $ipSet = false; 
    public $Sock = array(); 
    public $Sock2 = array(); 
    public $xSock = array("174.36.242.24", "174.36.242.25", "174.36.242.26", "174.36.242.27", "174.36.242.32", "174.36.242.33", "174.36.242.34", "174.36.242.35", "174.36.242.40", "174.36.242.41", "174.36.242.42", "174.36.242.43", "69.4.231.248", "69.4.231.249", "69.4.231.250", "69.4.231.251"); 
    public $xSock2 = array("208.43.218.80", "208.43.218.81", "208.43.218.82", "208.43.218.83", "174.36.56.200", "174.36.56.201", "174.36.56.202", "174.36.56.203", "174.36.4.144", "174.36.4.145", "174.36.4.146", "174.36.4.147", "174.36.56.184", "174.36.56.185", "174.36.56.186", "174.36.56.187"); 
    public $SockStatus = array(400, 401, 402, 403, 410, 411, 412, 413, 420, 421, 422, 423, 430, 431, 432, 433); 

    public function GetDom($arg1){ 
     if ($arg1 == 8){ 
      return (0); 
     } 
     return ((($arg1)<8) ? 3 : (($arg1 & 96) >> 5)); 
    } 

    public function GetPort($arg1){ 
     if ((integer)$arg1 == 8){ 
      return (10000); 
     } 
     return ((((integer)$arg1)<8) ? ((10000 - 1) + (integer)$arg1) : ((10000 + 7) + ((integer)$arg1 % 32))); 
    } 

    public function randomFloat(){ 
     $n = "0.".rand(0,9); 
     return $n; 
    } 
    public function setIps(){ 
     $local2 = array(); 
     $local3 = 0; 
     $local1 = 0; 
     while ($local1 < $this->xservers){ 
      $local2 = array(); 
      $local3 = 0; 
      while ($local3 < $this->xips) 
      { 
       $v = (($local1 * $this->xips) + $local3); 
       if ($this->SockStatus[$v] != 0){ 
        array_push($local2, $this->xSock[(($local1 * $this->xips) + $local3)]); 
       } 
       $local3++; 
      } 
      if (count($local2) > 0){ 
       $this->Sock[$local1] = $local2[round($this->randomFloat() * count($local2))]; 
      } 
      $local1++; 
     } 
    } 
    echo $this->Sock[$this->GetDom(5)]; 
    } 
?> 
+0

检查错误日志。 – 2012-08-08 00:37:19

+0

我知道:因为代码不好。老实说,这样质量的问题值得这样回答。你甚至没有试图解释“不工作”是什么意思,也没有试图自己解决这个问题。再次询问问题前阅读[常见问题]。这可能会很快关闭。 – Tadeck 2012-08-08 00:39:37

回答

2

在类的结尾处,您有这样的回声声明坐在里面的类(内部没有任何形式的功能):

echo $this->Sock[$this->GetDom(5)]; 

你应该把它移动到其自身的功能:

function output() 
{ 
    return $this->Sock[$this->GetDom(5)]; 
} 

然后从类的外部调用它:

$class = new Network(); 
$output = $class->output(); 

echo $output;