3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests = [ '/[$-\w]/', '/[\w-$]/', '/[\w-]/', '/[-\w]/', '/[$-]/', '/[-$]/', ]; foreach($tests as $test) { echo "$test\n"; preg_match($test,''); }
Output for 7.4.0 - 7.4.16, 8.0.0 - 8.0.3
/[$-\w]/ Warning: preg_match(): Compilation failed: invalid range in character class at offset 5 in /in/fk0Ij on line 14 /[\w-$]/ Warning: preg_match(): Compilation failed: invalid range in character class at offset 3 in /in/fk0Ij on line 14 /[\w-]/ /[-\w]/ /[$-]/ /[-$]/
Output for 7.3.16 - 7.3.28
/[$-\w]/ /[\w-$]/ Warning: preg_match(): Compilation failed: invalid range in character class at offset 3 in /in/fk0Ij on line 14 /[\w-]/ /[-\w]/ /[$-]/ /[-$]/
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33
/[$-\w]/ Warning: preg_match(): Compilation failed: invalid range in character class at offset 4 in /in/fk0Ij on line 14 /[\w-$]/ /[\w-]/ /[-\w]/ /[$-]/ /[-$]/