3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace ns1; class c1{} namespace ns1\c1; class c11{} namespace main; use ns1\c1; $c1 = new c1(); $c11 = new c1\c11(); function takes_c1(c1 $foo) { var_dump(get_class($foo)); } function takes_c11(c1\c11 $foo) { var_dump(get_class($foo)); } var_dump(get_class($c1)); // object(ns1\c1)#1 (0) { } var_dump(get_class($c11)); // object(ns1\c1\c11)#2 (0) { } takes_c1($c1); takes_c11($c11);
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.21, 8.3.0 - 8.3.9
string(6) "ns1\c1" string(10) "ns1\c1\c11" string(6) "ns1\c1" string(10) "ns1\c1\c11"

preferences:
251.13 ms | 404 KiB | 298 Q