为什么不能上课?

时间:2012-08-08 00:34:31

标签: php class

有没有人知道为什么我的代码不起作用,我尝试运行它但它不起作用,当我把它放在网上时说它无法加载页面。有什么我需要添加或什么?我出于某种原因无法让它发挥作用。

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

1 个答案:

答案 0 :(得分:2)

在课程的最后,你将这个echo语句放在类中(不在任何类型的函数中):

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

您应该将其移动到自己的功能中:

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

然后从班级外面打电话:

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

echo $output;