Is it possible to hide a specific class fields from print_r ?
<?php
class DataManager {
public $data = array();
}
class Data {
public $manager;
public $data = array();
public function Data ($m, $d) {
$this->manager = $m;
$this->data = $d;
}
}
$manager = new DataManager();
for ($a = 0; $a < 10; $a++) {
$manager->data[] = new Data($manager, 'Test ' . md5($a));
}
echo '<pre>';
print_r($manager);
?>
This would print
DataManager Object (
[data] => Array
(
[0] => Data Object
(
[manager] => DataManager Object RECURSION
[data] => Test cfcd208495d565ef66e7dff9f98764da
)
[1] => Data Object
(
[manager] => DataManager Object *RECURSION*
[data] => Test c4ca4238a0b923820dcc509a6f75849b
) .......
Is it possible to somehow change the output behavior so it print's like this? Like with DocComment /** @hidden **/
DataManager Object (
[data] => Array
(
[0] => Data Object
(
[data] => Test cfcd208495d565ef66e7dff9f98764da
)
[1] => Data Object
(
[data] => Test c4ca4238a0b923820dcc509a6f75849b
)
If not, is there some sort of PHP lib that maybe uses Reflection and somehow bypasses stuff?
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…