3v4l.org

run code in 300+ PHP versions simultaneously
<?php //===================================================================================== //Apply real_escape_string to strip out SQL injection function makeSafe($value){ //if (isset($value)){ $value = $this->clean_html($value); $value = strip_tags(trim($value)); //} return $value; //return mysql_real_escape_string($value); } //===================================================================================== //Clean out html code. From html2txt() in http://us2.php.net/manual/en/function.strip-tags.php function clean_html($document){ $search = array( '@<script[^>]*?>.*?</script>@si', // Strip out javascript '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags '@<style[^>]*?>.*?</style>@siU', // Strip style tags properly '@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments including CDATA ); //Replace any of the patterns listed above $text = preg_replace($search, '', $document); //Replace or remove any illegal characters $text = preg_replace('/;/', ' ', $text); //semicolons $text = preg_replace('/"/', "'", $text); //double quotations $text = preg_replace('/[\%\?\*]/', ' ', $text); //wildcards $text = preg_replace('/[\:\`\$\/\\\=\~\<\>\|\!\^]/', ' ', $text); //other uneeded symbols $text = preg_replace('/[-]{2,}/', '-', $text); //more than 1 dash in a row $text = preg_replace("/[\']{2,}/", "'", $text); //more than 1 single quotation in a row $text = preg_replace("/[\&]{2,}/", '&', $text); //more than 1 ampersand in a row $text = preg_replace("/[ ]{2,}/", ' ', $text); //more than 1 space in a row //And replace any leftover special characters $text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8'); //Return the value return $text; } $mystring = " rcooper@c2ti.com test 456 Famed California pollster Joe Shumate was found dead in his home one month before Election Day 2010, surrounded by sheets of polling data he labored over for the flailing Senate bid of Carly Fiorina. Upon his death, Fiorina praised Shumate as 'the heart and sou f her team. She issued a news release praising him as a person who believed in inves"; $mystring2 = makeSafe($mystring); echo $mystring2;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z7Tmm
function name:  (null)
number of ops:  7
compiled vars:  !0 = $mystring, !1 = $mystring2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   ASSIGN                                                   !0, '%0Arcooper%40c2ti.com+test+456%0A%0A++Famed+California+pollster+Joe+Shumate+was+found+dead+in+his+home+one+month+before+Election+Day+2010%2C+surrounded+by+sheets+of+polling+data+he+labored+over+for+the+flailing+Senate+bid+of+Carly+Fiorina.+Upon+his+death%2C+Fiorina+praised+Shumate+as+%27the+heart+and+sou+f+her+team.+She+issued+a+news+release+praising+him+as+a+person+who+believed+in+inves'
   58     1        INIT_FCALL                                               'makesafe'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   59     5        ECHO                                                     !1
          6      > RETURN                                                   1

Function makesafe:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z7Tmm
function name:  makeSafe
number of ops:  15
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    9     1        FETCH_THIS                                       $1      
          2        INIT_METHOD_CALL                                         $1, 'clean_html'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $2      
          5        ASSIGN                                                   !0, $2
   10     6        INIT_FCALL                                               'strip_tags'
          7        INIT_FCALL                                               'trim'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $4      
         10        SEND_VAR                                                 $4
         11        DO_ICALL                                         $5      
         12        ASSIGN                                                   !0, $5
   13    13      > RETURN                                                   !0
   15    14*     > RETURN                                                   null

End of function makesafe

Function clean_html:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z7Tmm
function name:  clean_html
number of ops:  64
compiled vars:  !0 = $document, !1 = $search, !2 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   25     1        ASSIGN                                                   !1, <array>
   33     2        INIT_FCALL                                               'preg_replace'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 ''
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !2, $4
   36     8        INIT_FCALL                                               'preg_replace'
          9        SEND_VAL                                                 '%2F%3B%2F'
         10        SEND_VAL                                                 '+'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                         $6      
         13        ASSIGN                                                   !2, $6
   37    14        INIT_FCALL                                               'preg_replace'
         15        SEND_VAL                                                 '%2F%22%2F'
         16        SEND_VAL                                                 '%27'
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                         $8      
         19        ASSIGN                                                   !2, $8
   38    20        INIT_FCALL                                               'preg_replace'
         21        SEND_VAL                                                 '%2F%5B%5C%25%5C%3F%5C%2A%5D%2F'
         22        SEND_VAL                                                 '+'
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                         $10     
         25        ASSIGN                                                   !2, $10
   39    26        INIT_FCALL                                               'preg_replace'
         27        SEND_VAL                                                 '%2F%5B%5C%3A%5C%60%5C%24%5C%2F%5C%5C%3D%5C%7E%5C%3C%5C%3E%5C%7C%5C%21%5C%5E%5D%2F'
         28        SEND_VAL                                                 '+'
         29        SEND_VAR                                                 !2
         30        DO_ICALL                                         $12     
         31        ASSIGN                                                   !2, $12
   40    32        INIT_FCALL                                               'preg_replace'
         33        SEND_VAL                                                 '%2F%5B-%5D%7B2%2C%7D%2F'
         34        SEND_VAL                                                 '-'
         35        SEND_VAR                                                 !2
         36        DO_ICALL                                         $14     
         37        ASSIGN                                                   !2, $14
   41    38        INIT_FCALL                                               'preg_replace'
         39        SEND_VAL                                                 '%2F%5B%5C%27%5D%7B2%2C%7D%2F'
         40        SEND_VAL                                                 '%27'
         41        SEND_VAR                                                 !2
         42        DO_ICALL                                         $16     
         43        ASSIGN                                                   !2, $16
   42    44        INIT_FCALL                                               'preg_replace'
         45        SEND_VAL                                                 '%2F%5B%5C%26%5D%7B2%2C%7D%2F'
         46        SEND_VAL                                                 '%26'
         47        SEND_VAR                                                 !2
         48        DO_ICALL                                         $18     
         49        ASSIGN                                                   !2, $18
   43    50        INIT_FCALL                                               'preg_replace'
         51        SEND_VAL                                                 '%2F%5B+%5D%7B2%2C%7D%2F'
         52        SEND_VAL                                                 '+'
         53        SEND_VAR                                                 !2
         54        DO_ICALL                                         $20     
         55        ASSIGN                                                   !2, $20
   46    56        INIT_FCALL                                               'htmlspecialchars'
         57        SEND_VAR                                                 !2
         58        SEND_VAL                                                 3
         59        SEND_VAL                                                 'UTF-8'
         60        DO_ICALL                                         $22     
         61        ASSIGN                                                   !2, $22
   49    62      > RETURN                                                   !2
   50    63*     > RETURN                                                   null

End of function clean_html

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.89 ms | 1407 KiB | 22 Q