-3

有谁知道为什么我的代码不起作用,我尝试运行它但它不起作用,当我把它放到网上时,它说页面无法加载。有什么我需要添加的吗?由于某种原因,我无法让它工作。

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)];
    }
?>
4

1 回答 1

2

在你的类的最后,你有这个 echo 语句位于类内(不是在任何类型的函数内):

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

你应该把它移到它自己的函数中:

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

然后从课堂外调用它:

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

echo $output;
于 2012-08-08T00:40:41.807 回答