3v4l.org

run code in 500+ 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.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
--- Warning: Attempt to read property "count" on null in /in/E4uk7 on line 6 NO count --- NO count

preferences:
48.28 ms | 842 KiB | 4 Q