3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DAL { function getNoAnnonces() { return array( "12334", "233455" ); } function getURLRecherches() { //$line = "Nissan, Rogue, 2008, 1000, 9000, 10000, 110000"; //$line2 = "Nissan, Rogue, 2009, 1000, 9000, 10000, 90000"; return array( "http://www.kijiji.ca/b-autos-camions/grand-montreal/suv+vgm-bmw-x5-2001__2009/c174l80002a138a54a1000054a68?sort=priceAsc&price=2000.00__40000.00&kilometres=10000__110000", "http://www.kijiji.ca/b-autos-camions/grand-montreal/suv+vgm-bmw-x5-2001__2009/c174l80002a138a54a1000054a68?sort=priceAsc&price=2000.00__40000.00&kilometres=10000__110000" //split(",", $line, 7), //split(",", $line2, 7) ); } } class AdsListExtractor { private $html; function __construct($a1) { $this->html = $a1; echo $this->html; echo "\n"; } function getURLs() { $regexa = '/\<a(.*)\<\/a\>/'; preg_match($regexa, $this->html, $matches); $a = $matches[1]; //echo $a; //echo "\n"; //echo "\n"; //Extract no d'annonces $regexno = '/name="(\d+)"/i'; preg_match($regexno, $a, $matches); //echo 'id:'; //echo $matches[1]; //echo "\n"; //Extract url des fiches $regexurl = '/href="(\S+)"/i'; preg_match($regexurl, $a, $matches); //echo 'url:'; //echo $matches[1]; echo "\n"; $url_fiche = 'http://www.kijiji.ca' . $matches[1]; echo $url_fiche; echo "\n"; return $matches; } } class AdInfoExtractor { private $html = 0; function __construct($a1) { $this->html = $a1; } function getHMTL() { echo '------'.$this->html; $regexatt = '/\<table class="ad-attributes">(.*)\<\/table\>/'; preg_match($regexatt, $this->html, $matches); $a = $matches[1]; $regexcontent = '/\<div id="UserContent">(.*)\<\/div\>/'; preg_match($regexcontent, $this->html, $matches); $b = $matches[1]; return $a . $b; } } class HTMLReader { function getHTML($url) { echo "\n"; echo 'url::'.$url; if ($url='http://www.kijiji.ca/b-autos-camions/grand-montreal/suv+vgm-nissan-rogue-2001__2009/c174l80002a138a54a1000054a68?sort=priceAsc&price=2000.00__40000.00&kilometres=10000__110000"') { echo "\n"; echo 'true'; return "liste <td class=\"description\"><a href=\"/v-autos-camions/ville-de-montreal/2008-bmw-x5-suv/568081363\" class=\"title enable-search-navigation-flag\" name=\"568081363\">2008 BMW X5 SUV</a><p>"; } else { echo "\n"; echo 'false'; return 'fiche <table class="ad-attributes">yesser</table> dfdssd <div id="UserContent">good</div> dfdfdf df df'; } echo "\n"; } } $dal = new DAL(); $mail_html = ''; foreach ($dal->getURLRecherches() as $line_num => $line) { echo $line; echo "\n"; $reader = new HTMLReader(); $liste = new AdsListExtractor($reader->getHTML($line)); foreach ($liste->getURLs() as $line_number => $line2) { $htmlfiche = $reader->getHTML($line2); $ad_info = new AdInfoExtractor($htmlfiche); $mail_html = $mail_html . $ad_info->getHMTL(); echo "\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 42
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 42
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 40
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 40
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 40
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/4jdIK
function name:  (null)
number of ops:  44
compiled vars:  !0 = $dal, !1 = $mail_html, !2 = $line, !3 = $line_num, !4 = $reader, !5 = $liste, !6 = $line2, !7 = $line_number, !8 = $htmlfiche, !9 = $ad_info
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  111     0  E >   NEW                                              $10     'DAL'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $10
  113     3        ASSIGN                                                   !1, ''
  114     4        INIT_METHOD_CALL                                         !0, 'getURLRecherches'
          5        DO_FCALL                                      0  $14     
          6      > FE_RESET_R                                       $15     $14, ->42
          7    > > FE_FETCH_R                                       ~16     $15, !2, ->42
          8    >   ASSIGN                                                   !3, ~16
  115     9        ECHO                                                     !2
  116    10        ECHO                                                     '%0A'
  118    11        NEW                                              $18     'HTMLReader'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !4, $18
  120    14        NEW                                              $21     'AdsListExtractor'
         15        INIT_METHOD_CALL                                         !4, 'getHTML'
         16        SEND_VAR_EX                                              !2
         17        DO_FCALL                                      0  $22     
         18        SEND_VAR_NO_REF_EX                                       $22
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !5, $21
  124    21        INIT_METHOD_CALL                                         !5, 'getURLs'
         22        DO_FCALL                                      0  $25     
         23      > FE_RESET_R                                       $26     $25, ->40
         24    > > FE_FETCH_R                                       ~27     $26, !6, ->40
         25    >   ASSIGN                                                   !7, ~27
  125    26        INIT_METHOD_CALL                                         !4, 'getHTML'
         27        SEND_VAR_EX                                              !6
         28        DO_FCALL                                      0  $29     
         29        ASSIGN                                                   !8, $29
  126    30        NEW                                              $31     'AdInfoExtractor'
         31        SEND_VAR_EX                                              !8
         32        DO_FCALL                                      0          
         33        ASSIGN                                                   !9, $31
  127    34        INIT_METHOD_CALL                                         !9, 'getHMTL'
         35        DO_FCALL                                      0  $34     
         36        CONCAT                                           ~35     !1, $34
         37        ASSIGN                                                   !1, ~35
  128    38        ECHO                                                     '%0A'
  124    39      > JMP                                                      ->24
         40    >   FE_FREE                                                  $26
  114    41      > JMP                                                      ->7
         42    >   FE_FREE                                                  $15
  130    43      > RETURN                                                   1

Class DAL:
Function getnoannonces:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4jdIK
function name:  getNoAnnonces
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E > > RETURN                                                   <array>
   11     1*     > RETURN                                                   null

End of function getnoannonces

Function geturlrecherches:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4jdIK
function name:  getURLRecherches
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E > > RETURN                                                   <array>
   23     1*     > RETURN                                                   null

End of function geturlrecherches

End of class DAL.

Class AdsListExtractor:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4jdIK
function name:  __construct
number of ops:  7
compiled vars:  !0 = $a1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   31     1        ASSIGN_OBJ                                               'html'
          2        OP_DATA                                                  !0
   32     3        FETCH_OBJ_R                                      ~2      'html'
          4        ECHO                                                     ~2
   33     5        ECHO                                                     '%0A'
   34     6      > RETURN                                                   null

End of function __construct

Function geturls:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4jdIK
function name:  getURLs
number of ops:  29
compiled vars:  !0 = $regexa, !1 = $matches, !2 = $a, !3 = $regexno, !4 = $regexurl, !5 = $url_fiche
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   ASSIGN                                                   !0, '%2F%5C%3Ca%28.%2A%29%5C%3C%5C%2Fa%5C%3E%2F'
   39     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAR                                                 !0
          3        FETCH_OBJ_R                                      ~7      'html'
          4        SEND_VAL                                                 ~7
          5        SEND_REF                                                 !1
          6        DO_ICALL                                                 
   41     7        FETCH_DIM_R                                      ~9      !1, 1
          8        ASSIGN                                                   !2, ~9
   48     9        ASSIGN                                                   !3, '%2Fname%3D%22%28%5Cd%2B%29%22%2Fi'
   49    10        INIT_FCALL                                               'preg_match'
         11        SEND_VAR                                                 !3
         12        SEND_VAR                                                 !2
         13        SEND_REF                                                 !1
         14        DO_ICALL                                                 
   55    15        ASSIGN                                                   !4, '%2Fhref%3D%22%28%5CS%2B%29%22%2Fi'
   56    16        INIT_FCALL                                               'preg_match'
         17        SEND_VAR                                                 !4
         18        SEND_VAR                                                 !2
         19        SEND_REF                                                 !1
         20        DO_ICALL                                                 
   59    21        ECHO                                                     '%0A'
   60    22        FETCH_DIM_R                                      ~15     !1, 1
         23        CONCAT                                           ~16     'http%3A%2F%2Fwww.kijiji.ca', ~15
         24        ASSIGN                                                   !5, ~16
   61    25        ECHO                                                     !5
   62    26        ECHO                                                     '%0A'
   63    27      > RETURN                                                   !1
   64    28*     > RETURN                                                   null

End of function geturls

End of class AdsListExtractor.

Class AdInfoExtractor:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4jdIK
function name:  __construct
number of ops:  4
compiled vars:  !0 = $a1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   70     0  E >   RECV                                             !0      
   72     1        ASSIGN_OBJ                                               'html'
          2        OP_DATA                                                  !0
   73     3      > RETURN                                                   null

End of function __construct

Function gethmtl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4jdIK
function name:  getHMTL
number of ops:  24
compiled vars:  !0 = $regexatt, !1 = $matches, !2 = $a, !3 = $regexcontent, !4 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   77     0  E >   FETCH_OBJ_R                                      ~5      'html'
          1        CONCAT                                           ~6      '------', ~5
          2        ECHO                                                     ~6
   78     3        ASSIGN                                                   !0, '%2F%5C%3Ctable+class%3D%22ad-attributes%22%3E%28.%2A%29%5C%3C%5C%2Ftable%5C%3E%2F'
   79     4        INIT_FCALL                                               'preg_match'
          5        SEND_VAR                                                 !0
          6        FETCH_OBJ_R                                      ~8      'html'
          7        SEND_VAL                                                 ~8
          8        SEND_REF                                                 !1
          9        DO_ICALL                                                 
   80    10        FETCH_DIM_R                                      ~10     !1, 1
         11        ASSIGN                                                   !2, ~10
   82    12        ASSIGN                                                   !3, '%2F%5C%3Cdiv+id%3D%22UserContent%22%3E%28.%2A%29%5C%3C%5C%2Fdiv%5C%3E%2F'
   83    13        INIT_FCALL                                               'preg_match'
         14        SEND_VAR                                                 !3
         15        FETCH_OBJ_R                                      ~13     'html'
         16        SEND_VAL                                                 ~13
         17        SEND_REF                                                 !1
         18        DO_ICALL                                                 
   84    19        FETCH_DIM_R                                      ~15     !1, 1
         20        ASSIGN                                                   !4, ~15
   86    21        CONCAT                                           ~17     !2, !4
         22      > RETURN                                                   ~17
   87    23*     > RETURN                                                   null

End of function gethmtl

End of class AdInfoExtractor.

Class HTMLReader:
Function gethtml:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4jdIK
function name:  getHTML
number of ops:  15
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   91     0  E >   RECV                                             !0      
   93     1        ECHO                                                     '%0A'
   94     2        CONCAT                                           ~1      'url%3A%3A', !0
          3        ECHO                                                     ~1
   95     4        ASSIGN                                           ~2      !0, 'http%3A%2F%2Fwww.kijiji.ca%2Fb-autos-camions%2Fgrand-montreal%2Fsuv%2Bvgm-nissan-rogue-2001__2009%2Fc174l80002a138a54a1000054a68%3Fsort%3DpriceAsc%26price%3D2000.00__40000.00%26kilometres%3D10000__110000%22'
          5      > JMPZ                                                     ~2, ->10
   97     6    >   ECHO                                                     '%0A'
   98     7        ECHO                                                     'true'
   99     8      > RETURN                                                   'liste+%3Ctd+class%3D%22description%22%3E%3Ca+href%3D%22%2Fv-autos-camions%2Fville-de-montreal%2F2008-bmw-x5-suv%2F568081363%22+class%3D%22title+enable-search-navigation-flag%22+name%3D%22568081363%22%3E2008+BMW+X5+SUV%3C%2Fa%3E%3Cp%3E'
          9*       JMP                                                      ->13
  103    10    >   ECHO                                                     '%0A'
  104    11        ECHO                                                     'false'
  105    12      > RETURN                                                   'fiche+%3Ctable+class%3D%22ad-attributes%22%3Eyesser%3C%2Ftable%3E+dfdssd+%3Cdiv+id%3D%22UserContent%22%3Egood%3C%2Fdiv%3E+dfdfdf+df+df'
  107    13*       ECHO                                                     '%0A'
  108    14*     > RETURN                                                   null

End of function gethtml

End of class HTMLReader.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.64 ms | 1400 KiB | 15 Q