3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $url = "http://blog.everymansoftware.com/2011/11/development-setup-for-neo4j-and-php_05.html"; $fileHeaders = @get_headers($url); if( $fileHeaders[0] == "HTTP/1.1 200 OK" || $fileHeaders[0] == "HTTP/1.0 200 OK") { $content = strip_html_tags(file_url_contents($url)); } //To fetch the $url by using cURL function file_url_contents($url){ $crl = curl_init(); $timeout = 30; curl_setopt ($crl, CURLOPT_URL,$url); curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); $ret = curl_exec($crl); curl_close($crl); return $ret; } //file_url_contents ENDS //To remove all the hidden text not displayed on a webpage function strip_html_tags($str){ $str = preg_replace('/(<|>)\1{2}/is', '', $str); $str = preg_replace( array(// Remove invisible content '@<head[^>]*?>.*?</head>@siu', '@<style[^>]*?>.*?</style>@siu', '@<script[^>]*?.*?</script>@siu', '@<noscript[^>]*?.*?</noscript>@siu', ), "", //replace above with nothing $str ); $str = replaceWhitespace($str); $str = strip_tags($str); return $str; } //function strip_html_tags ENDS //To replace all types of whitespace with a single space function replaceWhitespace($str) { $result = $str; foreach (array( " ", " \t", " \r", " \n", "\t\t", "\t ", "\t\r", "\t\n", "\r\r", "\r ", "\r\t", "\r\n", "\n\n", "\n ", "\n\t", "\n\r", ) as $replacement) { $result = str_replace($replacement, $replacement[0], $result); } return $str !== $result ? replaceWhitespace($result) : $result; } ?>
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
Jump found. Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
Jump found. Position 1 = -2
Branch analysis from position: 21
Branch analysis from position: 13
filename:       /in/36DA4
function name:  (null)
number of ops:  25
compiled vars:  !0 = $url, !1 = $fileHeaders, !2 = $content
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   ASSIGN                                                   !0, 'http%3A%2F%2Fblog.everymansoftware.com%2F2011%2F11%2Fdevelopment-setup-for-neo4j-and-php_05.html'
   3     1        BEGIN_SILENCE                                    ~4      
         2        INIT_FCALL                                               'get_headers'
         3        SEND_VAR                                                 !0
         4        DO_ICALL                                         $5      
         5        END_SILENCE                                              ~4
         6        ASSIGN                                                   !1, $5
   4     7        FETCH_DIM_R                                      $7      !1, 0
         8        IS_EQUAL                                         ~8      $7, 'HTTP%2F1.1+200+OK'
         9      > JMPNZ_EX                                         ~8      ~8, ->13
        10    >   FETCH_DIM_R                                      $9      !1, 0
        11        IS_EQUAL                                         ~10     $9, 'HTTP%2F1.0+200+OK'
        12        BOOL                                             ~8      ~10
        13    > > JMPZ                                                     ~8, ->21
   6    14    >   INIT_FCALL_BY_NAME                                       'strip_html_tags'
        15        INIT_FCALL_BY_NAME                                       'file_url_contents'
        16        SEND_VAR_EX                                              !0
        17        DO_FCALL                                      0  $11     
        18        SEND_VAR_NO_REF                               4          $11
        19        DO_FCALL                                      0  $12     
        20        ASSIGN                                                   !2, $12
  10    21    >   NOP                                                      
  22    22        NOP                                                      
  39    23        NOP                                                      
  50    24      > RETURN                                                   1

Function file_url_contents:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/36DA4
function name:  file_url_contents
number of ops:  32
compiled vars:  !0 = $url, !1 = $crl, !2 = $timeout, !3 = $ret
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  10     0  E >   RECV                                             !0      
  11     1        INIT_FCALL_BY_NAME                                       'curl_init'
         2        DO_FCALL                                      0  $4      
         3        ASSIGN                                                   !1, $4
  12     4        ASSIGN                                                   !2, 30
  13     5        INIT_FCALL_BY_NAME                                       'curl_setopt'
         6        SEND_VAR_EX                                              !1
         7        FETCH_CONSTANT                                   ~7      'CURLOPT_URL'
         8        SEND_VAL_EX                                              ~7
         9        SEND_VAR_EX                                              !0
        10        DO_FCALL                                      0          
  14    11        INIT_FCALL_BY_NAME                                       'curl_setopt'
        12        SEND_VAR_EX                                              !1
        13        FETCH_CONSTANT                                   ~9      'CURLOPT_RETURNTRANSFER'
        14        SEND_VAL_EX                                              ~9
        15        SEND_VAL_EX                                              1
        16        DO_FCALL                                      0          
  15    17        INIT_FCALL_BY_NAME                                       'curl_setopt'
        18        SEND_VAR_EX                                              !1
        19        FETCH_CONSTANT                                   ~11     'CURLOPT_CONNECTTIMEOUT'
        20        SEND_VAL_EX                                              ~11
        21        SEND_VAR_EX                                              !2
        22        DO_FCALL                                      0          
  16    23        INIT_FCALL_BY_NAME                                       'curl_exec'
        24        SEND_VAR_EX                                              !1
        25        DO_FCALL                                      0  $13     
        26        ASSIGN                                                   !3, $13
  17    27        INIT_FCALL_BY_NAME                                       'curl_close'
        28        SEND_VAR_EX                                              !1
        29        DO_FCALL                                      0          
  18    30      > RETURN                                                   !3
  19    31*     > RETURN                                                   null

End of function file_url_contents

Function strip_html_tags:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/36DA4
function name:  strip_html_tags
number of ops:  23
compiled vars:  !0 = $str
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  22     0  E >   RECV                                             !0      
  23     1        INIT_FCALL                                               'preg_replace'
         2        SEND_VAL                                                 '%2F%28%3C%7C%3E%29%5C1%7B2%7D%2Fis'
         3        SEND_VAL                                                 ''
         4        SEND_VAR                                                 !0
         5        DO_ICALL                                         $1      
         6        ASSIGN                                                   !0, $1
  24     7        INIT_FCALL                                               'preg_replace'
  26     8        SEND_VAL                                                 <array>
  31     9        SEND_VAL                                                 ''
        10        SEND_VAR                                                 !0
        11        DO_ICALL                                         $3      
        12        ASSIGN                                                   !0, $3
  33    13        INIT_FCALL_BY_NAME                                       'replaceWhitespace'
        14        SEND_VAR_EX                                              !0
        15        DO_FCALL                                      0  $5      
        16        ASSIGN                                                   !0, $5
  34    17        INIT_FCALL                                               'strip_tags'
        18        SEND_VAR                                                 !0
        19        DO_ICALL                                         $7      
        20        ASSIGN                                                   !0, $7
  35    21      > RETURN                                                   !0
  36    22*     > RETURN                                                   null

End of function strip_html_tags

Function replacewhitespace:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
Jump found. Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
Jump found. Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
Jump found. Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
Jump found. Position 1 = 21
Branch analysis from position: 21
Jump found. Position 1 = -2
Branch analysis from position: 20
Jump found. Position 1 = -2
Branch analysis from position: 12
filename:       /in/36DA4
function name:  replaceWhitespace
number of ops:  23
compiled vars:  !0 = $str, !1 = $result, !2 = $replacement
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  39     0  E >   RECV                                             !0      
  40     1        ASSIGN                                                   !1, !0
  42     2      > FE_RESET_R                                       $4      <array>, ->12
         3    > > FE_FETCH_R                                               $4, !2, ->12
  47     4    >   INIT_FCALL                                               'str_replace'
         5        SEND_VAR                                                 !2
         6        FETCH_DIM_R                                      $5      !2, 0
         7        SEND_VAR                                                 $5
         8        SEND_VAR                                                 !1
         9        DO_ICALL                                         $6      
        10        ASSIGN                                                   !1, $6
        11      > JMP                                                      ->3
        12    >   FE_FREE                                                  $4
  49    13        IS_NOT_IDENTICAL                                 ~8      !0, !1
        14      > JMPZ                                                     ~8, ->20
        15    >   INIT_FCALL_BY_NAME                                       'replaceWhitespace'
        16        SEND_VAR_EX                                              !1
        17        DO_FCALL                                      0  $9      
        18        QM_ASSIGN                                        ~10     $9
        19      > JMP                                                      ->21
        20    >   QM_ASSIGN                                        ~10     !1
        21    > > RETURN                                                   ~10
  50    22*     > RETURN                                                   null

End of function replacewhitespace

Generated using Vulcan Logic Dumper, using php 7.2.0