3v4l.org

run code in 300+ PHP versions simultaneously
<?php $thing = null; echo "\n---\n"; if ( $thing->count ) { echo "YES, there is a count.\n"; } else { echo "NO count\n"; } echo "\n---\n"; if ( $thing instanceof StdClass && $thing->count ) { echo "YES, there is a count.\n"; } else { echo "NO count\n"; }
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
--- Warning: Attempt to read property "count" on null in /in/E4uk7 on line 6 NO count --- NO count

preferences:
40.72 ms | 406 KiB | 5 Q