2012-08-08 164 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;