- json_encode: documentation ( source)
<?php
class C implements JsonSerializable {
var $a = 'lol';
var $b = 'fa';
public function jsonSerialize() {
echo __METHOD__, PHP_EOL;
$aux = clone($this);
unset($aux->a);
return $aux;
}
}
echo json_encode(new C());