3v4l.org

run code in 300+ PHP versions simultaneously
<?php $css=<<<CSS p.special { font: 12pt/14pt sans-serif; margin: 5px 0px 2px 25px; border: medium dashed #ff0000; background: white url( http://www.foo.com/image.gif ) repeat-x fixed top right; } /************************************************* Save with a name ending in .css such as styles.css *************************************************/ h1 { color: red; padding: 10px; text-decoration: underline; } .code_sample ul { list-style-type: upper-roman; /* LEAVE THIS BIT OUT */ margin-left: 50px; } .code_sample p { color: darkblue } a:link, a:visited, a:hover, a:active { background-color: green; color: white; padding: 10px 25px; text-align: center; text-decoration: none; display: inline-block; } CSS; $patterns=[ '~\s+~', // reduce one or more consecutive whitespace characters ([\n\r \t]+) to a single space ...this combines the 2nd, 3rd, and 4th pattern from catchamonkey's answer '~/\s*\*.*?\*/\s*|(?:(?<=[,:;{}(]) | (?=[,:;{})]))|;(?=})|^ | $~s' // comment blocks, leading/trailing spaces after ,:;{} characters, space before ), space after (, semicolon followed by }, whitespace at start/end of file ]; $replacements=[ ' ', '' ]; // And here's a rabbit hole: https://regex101.com/r/nZbHND/1 var_export(preg_replace($patterns,$replacements,$css));
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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
'p.special{font:12pt/14pt sans-serif;margin:5px 0px 2px 25px;border:medium dashed #ff0000;background:white url(http://www.foo.com/image.gif) repeat-x fixed top right;}h1{color:red;padding:10px;text-decoration:underline;}.code_sample ul{list-style-type:upper-roman;margin-left:50px;}.code_sample p{color:darkblue}a:link,a:visited,a:hover,a:active{background-color:green;color:white;padding:10px 25px;text-align:center;text-decoration:none;display:inline-block;}'
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 'p.special{font:12pt/14pt sans-serif;margin:5px 0px 2px 25px;border:medium dashed #ff0000;background:white url(http://www.foo.com/image.gif) repeat-x fixed top right;}h1{color:red;padding:10px;text-decoration:underline;}.code_sample ul{list-style-type:upper-roman;margin-left:50px;}.code_sample p{color:darkblue}a:link,a:visited,a:hover,a:active{background-color:green;color:white;padding:10px 25px;text-align:center;text-decoration:none;display:inline-block;}'

preferences:
212.41 ms | 403 KiB | 289 Q