dump a class
- From: linux@xxxxxxxxxxxxxx (Alex Toro)
- Date: Thu, 29 Nov 2007 18:16:31 +0100
Hello, I would like to know why when I print_r or var_dump an object I
get the private properties. I give you an example:
<?php
class test
{
private $myPrivate = 'topsecret';
}
$myTest = new test();
#echo $myTest->myPrivate; // Fatal error: Cannot access private property
test::$myPrivate in ..... that's OK!
echo '<pre>';
print_r($myTest);
#test Object
#(
# [myPrivate:private] => topsecret
#)
var_dump($myTest);
#object(test)#1 (1) {
# ["myPrivate:private"]=>
# string(9) "topsecret"
#}
echo '</pre>';
?>
A private member is suposed to be private, isn't it?
Alex
.
- Follow-Ups:
- Re: [PHP] dump a class
- From: Robert Cummings
- Re: [PHP] dump a class
- Prev by Date: Glob
- Next by Date: Re: [PHP] Glob
- Previous by thread: Glob
- Next by thread: Re: [PHP] dump a class
- Index(es):