假设我有这个变量:
$my_query_object = $previous_connection->query($my_query);
根据 php.net 的那个 mysqli_result
对象有几个方法和这些属性:
int $current_field ;
int $field_count;
array $lengths;
int $num_rows;
很酷..但是如果我
print_r($my_query_object)
我在对象描述的末尾得到这个属性 [type] => 0
问题 1:
这个属性是什么以及为什么它没有在 mysqli_result
页面中提及?!
问题 2: 如何打印/回显/记录/列出对象的方法和属性 如果我不能同时执行这两项操作(在一个命令中打印属性和方法),至少我怎么能打印一个对象的方法,厌倦了来回到 php.net 只是为了检查对象的解剖结构..
谢谢
最佳答案
这在 fetch-all
的文档中有最好的解释。 :
resulttype
This optional parameter is a constant indicating what type of array should be produced from the current row data. The possible values for this parameter are the constants
MYSQLI_ASSOC
,MYSQLI_NUM
, orMYSQLI_BOTH
.
要获取对象的属性,可以使用 get_object_vars()
:
class foo { private $a; public $b = 1; public $c; private $d; static $e; public function test() { var_dump(get_object_vars($this)); } } $test = new foo; var_dump(get_object_vars($test)); $test->test();
关于php - mysqli_result 对象中的 'type' 属性代表什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52305140/