阿江 2017-09-30 14:56:33 1580次浏览 0条回复 0 0 0

说明

学习Yii Framework 2易2框架的过程是漫长的也是充满乐趣的以下是我学习Yii2框架时对官网英文资料(请参见原文网址)的代码实现提供了较完整的代码供你参考不妥之处请多多指正

原文网址:

http://php.net/manual/en/function.get-object-vars.php

本文主题:输出类或对象的所有属性和方法

一、输出类的所有属性和方法:

源代码:

		echo "Query6:<br>";
		$query=new \yii\mongodb\Query;
		$customers =$query->select(['name','population'])
			->from('country')
			->where(['not between','population',20,100000000]);
		echo "<br>vars:<br>";
		$vars = get_class_vars('\yii\mongodb\Query');
		print_r($vars);
		echo "<br><br>methods:<br>";
		$methods = get_class_methods('\yii\mongodb\Query');
		print_r($methods);
测试
Query6:
vars:
Array ( [select] => Array ( ) [from] => [options] => Array ( ) [where] => [limit] => [offset] => [orderBy] => [indexBy] => ) 

methods:
Array ( [0] => getCollection [1] => select [2] => from [3] => options [4] => addOptions [5] => andFilterCompare [6] => all [7] => populate [8] => one [9] => modify [10] => count [11] => exists [12] => sum [13] => average [14] => min [15] => max [16] => distinct [17] => __get [18] => __set [19] => __isset [20] => __unset [21] => __call [22] => __clone [23] => hasProperty [24] => canGetProperty [25] => canSetProperty [26] => hasMethod [27] => behaviors [28] => hasEventHandlers [29] => on [30] => off [31] => trigger [32] => getBehavior [33] => getBehaviors [34] => attachBehavior [35] => attachBehaviors [36] => detachBehavior [37] => detachBehaviors [38] => ensureBehaviors [39] => className [40] => __construct [41] => init [42] => indexBy [43] => where [44] => andWhere [45] => orWhere [46] => filterWhere [47] => andFilterWhere [48] => orFilterWhere [49] => orderBy [50] => addOrderBy [51] => limit [52] => offset )

二、输出对象的所有属性:

源代码:
		echo "Query6:<br>";
		$query=new \yii\mongodb\Query;
		$customers =$query->select(['name','population'])
			->from('country')
			->where(['not between','population',20,100000000]);
// 		$methods = get_object_methods($query);//没有这个方法
		echo "<br>vars:<br>";
		$vars = get_object_vars($query);
		print_r($vars);
测试
Query6:
vars:
Array ( [select] => Array ( [0] => name [1] => population ) [from] => country [options] => Array ( ) [where] => Array ( [0] => not between [1] => population [2] => 20 [3] => 100000000 ) [limit] => [offset] => [orderBy] => [indexBy] => )

(全文完)

    没有找到数据。
您需要登录后才可以回复。登录 | 立即注册