1
クラス内のすべてのパブリック変数をクラス内からループする方法はありますか?すべてのパブリック変数をループし、NULL値を空の文字列に変換する
パブリック変数の取得方法は?
private function translate_null_values_to_strings(){
foreach($this->public_vars as $key => $value){
if(is_null($this->$key)) $this->$key = '';
}
}
http://stackoverflow.com/questions/3309320/php-get-classes私はあなたが欲しいものを得るためにPHPのマニュアルからの例を変更しました-public-variables – vaso123
['ReflectionClass :: getProperties'](http://php.net/manual/en/reflectionclass.getproperties.php)'(ReflectionProperty :: IS_PUBLIC) ' –
私はこれをやることを避けます。あなたのアプリケーションで間違っている場合は、オブジェクトがいくつかのプロパティを持っている場合は、後でしたくない値が設定されています.. –