3v4l.org

run code in 300+ PHP versions simultaneously
<style> textarea { padding: 10px; margin-top: 5px; width: 3px; height: 150px; width:350px; font-size:15px; border-radius:3px; border:1px solid lightgrey; } textarea:focus { color: red; border:1px solid red; outline:none; } #functions { border:1px solid lightgrey; width:350px; padding-top:5px; padding-bottom:5px; margin:0 auto; border-radius:5px; } #functions:hover { border:1px solid red; } input[type=button] { color:red; padding-left:5px; padding-right:5px; background-color: lightgrey; border:none; border-radius:5px; outline:none; font-size:13px; cursor: pointer; } input[type=button]:active { background-color:darkgrey; } input[type=button]:hover { background-color:red; color:lightgrey; } button { color:white; background-color: red; font-size:15px; border:none; outline:none; border-radius:4px; cursor: pointer; margin-top: 5px; } button:active { font-size:17px; } body { background-color: lightgrey; } #parser { background-color:white; border-radius:5px; text-align: center; width: 350px; margin:0 auto; padding:15px; } #live { background-color:white; border-radius:5px; text-align: center; width: 350px; margin:0 auto; margin-top:20px; padding:15px; font-size:10px; } #output { border:1px solid red; border-radius:5px; width:100%; font-size:14px; padding:5px; } </style> <script> function formatText(tag) { var Field = document.getElementById('comment'); var val = Field.value; var selected_txt = val.substring(Field.selectionStart, Field.selectionEnd); var before_txt = val.substring(0, Field.selectionStart); var after_txt = val.substring(Field.selectionEnd, val.length); Field.value += '[' + tag + ']' + '[/' + tag + ']'; } </script> <body> <div id="parser"> <div id="functions"> <input type="button" value="Bold" onclick="formatText ('b');" /> <input type="button" value="Italic" onclick="formatText ('i');" /> <input type="button" value="Underline" onclick="formatText ('u');" /> <input type="button" value="Code" onclick="formatText ('quote');" /> <input type="button" value="URL" onclick="formatText ('url');" /> <input type="button" value="IMG" onclick="formatText ('img');" /> </div> <form method="post"> <textarea name="comment" id="comment"></textarea> <br> <button>Parse</button> </form> </div> </body> <?php //BBCode Parser function function showBBcodes($text) { // BBcode array $find = array( '~\[b\](.*?)\[/b\]~s', '~\[i\](.*?)\[/i\]~s', '~\[u\](.*?)\[/u\]~s', '~\[quote\](.*?)\[/quote\]~s', '~\[size=(.*?)\](.*?)\[/size\]~s', '~\[color=(.*?)\](.*?)\[/color\]~s', '~\[url\]((?:ftp|https?)://.*?)\[/url\]~s', '~\[img\](https?://.*?\.(?:jpg|jpeg|gif|png|bmp))\[/img\]~s' ); // HTML tags to replace BBcode $replace = array( '<b>$1</b>', '<i>$1</i>', '<span style="text-decoration:underline;">$1</span>', '<pre>$1</'.'pre>', '<span style="font-size:$1px;">$2</span>', '<span style="color:$1;">$2</span>', '<a href="$1">$1</a>', '<img src="$1" alt="" />' ); // Replacing the BBcodes with corresponding HTML tags return preg_replace($find,$replace,$text); } // How to use the above function: if ($_POST){ $bbtext = $_POST['comment']; $htmltext = showBBcodes($bbtext); ?> <div id="live"> <p> Live </p> <div id="output"> <?php echo $htmltext; ?> </div> </div> <?php } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/3Ta5Q
function name:  (null)
number of ops:  14
compiled vars:  !0 = $bbtext, !1 = $htmltext
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   ECHO                                                     '%3Cstyle%3E%0A%09textarea+%7B%0A%09%09padding%3A+10px%3B%0A%09%09margin-top%3A+5px%3B%0A%09%09width%3A+3px%3B%0A%09%09height%3A+150px%3B%0A%09%09width%3A350px%3B%0A%09%09font-size%3A15px%3B%0A%09%09border-radius%3A3px%3B%0A%09%09border%3A1px+solid+lightgrey%3B%0A%09%7D%0A%09textarea%3Afocus+%7B%0A%09%09color%3A+red%3B%0A%09%09border%3A1px+solid+red%3B%0A%09%09outline%3Anone%3B%0A%09%7D%0A%09%23functions+%7B%0A%09%09border%3A1px+solid+lightgrey%3B%0A%09%09width%3A350px%3B%0A%09%09padding-top%3A5px%3B%0A%09%09padding-bottom%3A5px%3B%0A%09%09margin%3A0+auto%3B%0A%09%09border-radius%3A5px%3B%0A%09%7D%0A%09%23functions%3Ahover+%7B%0A%09%09border%3A1px+solid+red%3B%0A%09%7D%0A%09input%5Btype%3Dbutton%5D+%7B%0A%09%09color%3Ared%3B%0A%09%09padding-left%3A5px%3B%0A%09%09padding-right%3A5px%3B%0A%09%09background-color%3A+lightgrey%3B%0A%09%09border%3Anone%3B%0A%09%09border-radius%3A5px%3B%0A%09%09outline%3Anone%3B%0A%09%09font-size%3A13px%3B%0A%09%09cursor%3A+pointer%3B%0A%09%7D%0A%09input%5Btype%3Dbutton%5D%3Aactive+%7B%0A%09%09background-color%3Adarkgrey%3B%0A%09%7D%0A%09input%5Btype%3Dbutton%5D%3Ahover+%7B%0A%09%09background-color%3Ared%3B%0A%09%09color%3Alightgrey%3B%0A%09%7D%0A%09button+%7B%0A%09%09color%3Awhite%3B%0A%09%09background-color%3A+red%3B%0A%09%09font-size%3A15px%3B%0A%09%09border%3Anone%3B%0A%09%09outline%3Anone%3B%0A%09%09border-radius%3A4px%3B%0A%09%09cursor%3A+pointer%3B%0A%09%09margin-top%3A+5px%3B%0A%09%7D%0A%09button%3Aactive+%7B%0A%09%09font-size%3A17px%3B%0A%09%7D%0A%09body+%7B%0A%09%09background-color%3A+lightgrey%3B%0A%09%7D%0A%09%23parser+%7B%0A%09%09background-color%3Awhite%3B%0A%09%09border-radius%3A5px%3B%0A%09%09text-align%3A+center%3B%0A%09%09width%3A+350px%3B%0A%09%09margin%3A0+auto%3B%0A%09%09padding%3A15px%3B%0A%09%7D%0A%09%23live+%7B%0A%09%09background-color%3Awhite%3B%0A%09%09border-radius%3A5px%3B%0A%09%09text-align%3A+center%3B%0A%09%09width%3A+350px%3B%0A%09%09margin%3A0+auto%3B%0A%09%09margin-top%3A20px%3B%0A%09%09padding%3A15px%3B%0A%09%09font-size%3A10px%3B%0A%09%7D%0A%09%23output+%7B%0A%09%09border%3A1px+solid+red%3B%0A%09%09border-radius%3A5px%3B%0A%09%09width%3A100%25%3B%0A%09%09font-size%3A14px%3B%0A%09%09padding%3A5px%3B%0A%09%7D%0A%3C%2Fstyle%3E%0A%3Cscript%3E%0A%09function+formatText%28tag%29+%7B%0A%09%09var+Field+%3D+document.getElementById%28%27comment%27%29%3B%0A%09%09var+val+%3D+Field.value%3B%0A%09%09var+selected_txt+%3D+val.substring%28Field.selectionStart%2C+Field.selectionEnd%29%3B%0A%09%09var+before_txt+%3D+val.substring%280%2C+Field.selectionStart%29%3B%0A%09%09var+after_txt+%3D+val.substring%28Field.selectionEnd%2C+val.length%29%3B%0A%09%09Field.value+%2B%3D+%27%5B%27+%2B+tag+%2B+%27%5D%27+%2B+%27%5B%2F%27+%2B+tag+%2B+%27%5D%27%3B%0A%09%7D%0A%3C%2Fscript%3E%0A%3Cbody%3E%0A%09%3Cdiv+id%3D%22parser%22%3E%0A%09%09%3Cdiv+id%3D%22functions%22%3E%0A%09%09%09%3Cinput+type%3D%22button%22+value%3D%22Bold%22+onclick%3D%22formatText+%28%27b%27%29%3B%22+%2F%3E%0A%09%09%09%3Cinput+type%3D%22button%22+value%3D%22Italic%22+onclick%3D%22formatText+%28%27i%27%29%3B%22+%2F%3E%0A%09%09%09%3Cinput+type%3D%22button%22+value%3D%22Underline%22+onclick%3D%22formatText+%28%27u%27%29%3B%22+%2F%3E%0A%09%09%09%3Cinput+type%3D%22button%22+value%3D%22Code%22+onclick%3D%22formatText+%28%27quote%27%29%3B%22+%2F%3E%0A%09%09%09%3Cinput+type%3D%22button%22+value%3D%22URL%22+onclick%3D%22formatText+%28%27url%27%29%3B%22+%2F%3E%0A%09%09%09%3Cinput+type%3D%22button%22+value%3D%22IMG%22+onclick%3D%22formatText+%28%27img%27%29%3B%22+%2F%3E%0A%09%09%3C%2Fdiv%3E%0A%09%09%3Cform+method%3D%22post%22%3E%0A%09%09%09%3Ctextarea+name%3D%22comment%22+id%3D%22comment%22%3E%3C%2Ftextarea%3E%0A%09%09%09%3Cbr%3E%0A%09%09%09%3Cbutton%3EParse%3C%2Fbutton%3E%0A%09%09%3C%2Fform%3E%0A%09%3C%2Fdiv%3E%0A%3C%2Fbody%3E%0A'
  144     1        FETCH_R                      global              ~2      '_POST'
          2      > JMPZ                                                     ~2, ->13
  145     3    >   FETCH_R                      global              ~3      '_POST'
          4        FETCH_DIM_R                                      ~4      ~3, 'comment'
          5        ASSIGN                                                   !0, ~4
  146     6        INIT_FCALL                                               'showbbcodes'
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0  $6      
          9        ASSIGN                                                   !1, $6
  148    10        ECHO                                                     '%3Cdiv+id%3D%22live%22%3E%0A%09%3Cp%3E%0A%09%09Live%0A%09%3C%2Fp%3E%0A%09%3Cdiv+id%3D%22output%22%3E%0A%09%09'
  153    11        ECHO                                                     !1
  154    12        ECHO                                                     '%09%3C%2Fdiv%3E%0A%3C%2Fdiv%3E%0A'
  158    13    > > RETURN                                                   1

Function showbbcodes:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3Ta5Q
function name:  showBBcodes
number of ops:  10
compiled vars:  !0 = $text, !1 = $find, !2 = $replace
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  117     0  E >   RECV                                             !0      
  119     1        ASSIGN                                                   !1, <array>
  130     2        ASSIGN                                                   !2, <array>
  141     3        INIT_FCALL                                               'preg_replace'
          4        SEND_VAR                                                 !1
          5        SEND_VAR                                                 !2
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $5      
          8      > RETURN                                                   $5
  142     9*     > RETURN                                                   null

End of function showbbcodes

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.51 ms | 1394 KiB | 16 Q