- var_dump: documentation ( source)
<?php
class Foo {
private $value = 42;
public function property( $value = null ) {
$ret = $this->value;
if ( func_num_args() === 0 ) {
echo "Called as getter!\n";
} else {
echo "Called as setter!\n";
$this->value = $value;
}
return $ret;
}
}
$foo = new Foo;
echo "Calling as getter...\n";
var_dump( $foo->property() );
echo "Calling as setter...\n";
var_dump( $foo->property( 123 ) );
echo "Calling as setter, passing null...\n";
var_dump( $foo->property( null ) );
echo "Calling as getter...\n";
var_dump( $foo->property() );