Php 数据库中带有数组的私有类

Php 数据库中带有数组的私有类,php,arrays,class,Php,Arrays,Class,我有一个带有数组的私有类: class Whois{ private $whoisServers = array( "ac"=> "whois.nic.ac", "ae" => "whois.nic.ae", "tech" => "whois.nic.tech", "yu" => "whois.ripe.net"); } 现在,我可能从数据库中获取私有$whoisServers的数组()。现在将对象设置为类并访问公共函数 <

我有一个带有数组的私有类:

class Whois{
    private $whoisServers = array(
  "ac"=> "whois.nic.ac",
  "ae" => "whois.nic.ae",
  "tech" => "whois.nic.tech",
  "yu" => "whois.ripe.net");
}

现在,我可能从数据库中获取私有$whoisServers的数组()。

现在将对象设置为类并访问公共函数

        <?php
class Whois{

    private $whoisServers = array(
      "ac"=> "whois.nic.ac",
      "ae" => "whois.nic.ae",
      "tech" => "whois.nic.tech",
      "yu" => "whois.ripe.net");


    /*
    !----------------------------------------------
    ! Getting Private Server List Using Public Function
    ! @getter
    !----------------------------------------------
    */
    public function getWhichServers()
    {
        return $this->whoisServers;
    }

    /*
        https://github.com/arif98741
    */
}

$object     = new Whois();
$serverlist = $object->getWhichServers();

现在创建类的对象并访问公共函数

        <?php
class Whois{

    private $whoisServers = array(
      "ac"=> "whois.nic.ac",
      "ae" => "whois.nic.ae",
      "tech" => "whois.nic.tech",
      "yu" => "whois.ripe.net");


    /*
    !----------------------------------------------
    ! Getting Private Server List Using Public Function
    ! @getter
    !----------------------------------------------
    */
    public function getWhichServers()
    {
        return $this->whoisServers;
    }

    /*
        https://github.com/arif98741
    */
}

$object     = new Whois();
$serverlist = $object->getWhichServers();

创建对象后,不能直接访问类的私有值。但是为了获得私有变量的值,您应该做一个getter。我在下面给出答案。。。。创建对象后,不能直接访问类的私有值。但是为了获得私有变量的值,您应该做一个getter。我在下面给出答案。。。。