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.31, 8.3.0 - 8.3.31, 8.4.1 - 8.4.22, 8.5.0 - 8.5.8
--- Warning: Attempt to read property "count" on null in /in/E4uk7 on line 6 NO count --- NO count

preferences:
35.46 ms | 874 KiB | 4 Q