1
私はPHPのOOPでの初心者ですが、私は次のように国と呼ばれるクラスを作成している:私は "致命的なエラー:定義されていない関数getCountries()"をPHP oopで呼び出すのを続けるのはなぜですか?
countries.php
class countries {
public $countries = array("Afghanistan","Hong Kong","Moldova","Malawi");
public function getCountries() {
return $countries;
}
}
test.phpを
require_once('/lbs/countries.php');
$country = new countries();
print_r($country->{getCountries()});
を私の推測):) –
なぜメソッド '{getCountries()}'の周りに中括弧がありますか? –
getCountries()を定義する本当の方法は何ですか? :) – Hassan