3v4l.org

run code in 300+ PHP versions simultaneously
<?php function wp_kses_split( $string, $allowed_html, $allowed_protocols ) { return preg_replace_callback( '%(<!--.*?(-->|$))|(<[^>]*(>|$)|>)%', function( $match ) use ($allowed_html, $allowed_protocols) { return wp_kses_split2( $match[0], $allowed_html, $allowed_protocols ); }, $string ); } function wp_kses_split2($string, $allowed_html, $allowed_protocols) { $string = str_replace( '\\"', '"', $string ); if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches)) { return ''; } $slash = trim($matches[1]); $elem = $matches[2]; $attrlist = $matches[3]; if ($slash != '') return "</$elem>"; return wp_kses_attr( $elem, $attrlist, $allowed_html, $allowed_protocols ); } function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) { $attrarr = array( array( 'name' => 'style', 'value' => '', 'whole' => "name=''", 'vless' => 'style' ) ); // Go through $attrarr, and save the allowed attributes for this element // in $attr2 $attr2 = ''; foreach ( $attrarr as $arreach ) { if ( wp_kses_attr_check( $arreach['name'], $arreach['value'], $arreach['whole'], $arreach['vless'], $element, $allowed_html ) ) { $attr2 .= ' '.$arreach['whole']; } } return "<$element$attr2>"; } function wp_kses_attr_check( &$name, &$value, &$whole, $vless, $element, $allowed_html ) { $allowed_attr = $allowed_html[strtolower( $element )]; $name_low = strtolower( $name ); if ( ! isset( $allowed_attr[$name_low] ) || '' == $allowed_attr[$name_low] ) { $name = $value = $whole = ''; return false; } if ( 'style' == $name_low ) { $new_value = safecss_filter_attr( $value ); if ( empty( $new_value ) ) { $name = $value = $whole = ''; return false; } $whole = str_replace( $value, $new_value, $whole ); $value = $new_value; } return true; } function safecss_filter_attr( $css, $element = 'div' ) { $css = $element . ' {' . $css . '}'; $css = wp_kses_split( $css, array(), array() ); $old = @setlocale(LC_ALL, 0); @setlocale(LC_ALL, 'C'); preg_match( "/[^\s\r\n\t\f]/", $css{0} ); @setlocale(LC_ALL, $old); return ''; } $content = '<p style="">hola</p><p style="">hola</p>'; var_dump( wp_kses_split( addslashes( $content ), array('p'=>array('style' => array())), array() ) );
Output for 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
Fatal error: Array and string offset access syntax with curly braces is no longer supported in /in/SM0Il on line 57
Process exited with code 255.
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 Fatal error: Array and string offset access syntax with curly braces is no longer supported in /in/SM0Il on line 57
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Deprecated: Array and string offset access syntax with curly braces is deprecated in /in/SM0Il on line 57 string(22) "<p>hola</p><p>hola</p>"
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 7.3.33
string(22) "<p>hola</p><p>hola</p>"

preferences:
169.42 ms | 402 KiB | 203 Q