Counting a PHP stdClass Object $obj = new stdClass; $obj->one = 1; $obj->two = 2; $vars = get_object_vars($obj); echo count($vars);