1<?php 2 3$c = new class { 4 public function hello() { echo "hello"; } 5}; 6 7$c->hello(); 8 9$d = new class(42) { 10 public function __construct($n) { echo $n; } 11 public function hello() { echo "hello"; } 12}; 13 14$d->hello(); 15 16class SomeClass {} 17interface SomeInterface {} 18trait SomeTrait {} 19 20$e = new class(64) extends SomeClass implements SomeInterface { 21 use SomeTrait; 22 public function __construct($n) { echo $n; } 23 public function hello() { echo "hello"; } 24}; 25 26$e->hello(); 27