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-nissan-rogue-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; } 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() { $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 getHMTL($url) { return 'dhoaudg od oaeywgdoad <table class="ad-attributes">yesser</table> dfdssd <div id="UserContent">good</div> dfdfdf df df'; } } //'http://montreal.kijiji.ca/c-ViewAd?AdId=576130148' $url_liste = "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"; $html_test = "<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>"; //$html_liste = file_get_contents($url_liste); $dal = new DAL(); foreach ($dal->getURLRecherches() as $line_num => $line) { $reader = new HTMLReader(); $liste = new AdsListExtractor($reader->getHMTL($line)); echo $line; echo "\n"; foreach ($liste->getURLs() as $line_num => $line) { $htmlfiche = $reader->getHMTL($line); $ad_info = new AdInfoExtractor($htmlfiche); echo $ad_info->getHMTL(); echo "\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 42
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 42
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 40
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 40
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
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/vP47X
function name:  (null)
number of ops:  44
compiled vars:  !0 = $url_liste, !1 = $html_test, !2 = $dal, !3 = $line, !4 = $line_num, !5 = $reader, !6 = $liste, !7 = $htmlfiche, !8 = $ad_info
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   97     0  E >   ASSIGN                                                   !0, 'http%3A%2F%2Fwww.kijiji.ca%2Fb-autos-camions%2Fgrand-montreal%2Fsuv%2Bvgm-bmw-x5-2001__2009%2Fc174l80002a138a54a1000054a68%3Fsort%3DpriceAsc%26price%3D2000.00__40000.00%26kilometres%3D10000__110000'
   99     1        ASSIGN                                                   !1, '%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'
  103     2        NEW                                              $11     'DAL'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !2, $11
  105     5        INIT_METHOD_CALL                                         !2, 'getURLRecherches'
          6        DO_FCALL                                      0  $14     
          7      > FE_RESET_R                                       $15     $14, ->42
          8    > > FE_FETCH_R                                       ~16     $15, !3, ->42
          9    >   ASSIGN                                                   !4, ~16
  106    10        NEW                                              $18     'HTMLReader'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !5, $18
  107    13        NEW                                              $21     'AdsListExtractor'
         14        INIT_METHOD_CALL                                         !5, 'getHMTL'
         15        SEND_VAR_EX                                              !3
         16        DO_FCALL                                      0  $22     
         17        SEND_VAR_NO_REF_EX                                       $22
         18        DO_FCALL                                      0          
         19        ASSIGN                                                   !6, $21
  109    20        ECHO                                                     !3
  110    21        ECHO                                                     '%0A'
  112    22        INIT_METHOD_CALL                                         !6, 'getURLs'
         23        DO_FCALL                                      0  $25     
         24      > FE_RESET_R                                       $26     $25, ->40
         25    > > FE_FETCH_R                                       ~27     $26, !3, ->40
         26    >   ASSIGN                                                   !4, ~27
  113    27        INIT_METHOD_CALL                                         !5, 'getHMTL'
         28        SEND_VAR_EX                                              !3
         29        DO_FCALL                                      0  $29     
         30        ASSIGN                                                   !7, $29
  114    31        NEW                                              $31     'AdInfoExtractor'
         32        SEND_VAR_EX                                              !7
         33        DO_FCALL                                      0          
         34        ASSIGN                                                   !8, $31
  115    35        INIT_METHOD_CALL                                         !8, 'getHMTL'
         36        DO_FCALL                                      0  $34     
         37        ECHO                                                     $34
  116    38        ECHO                                                     '%0A'
  112    39      > JMP                                                      ->25
         40    >   FE_FREE                                                  $26
  105    41      > JMP                                                      ->8
         42    >   FE_FREE                                                  $15
  118    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/vP47X
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/vP47X
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/vP47X
function name:  __construct
number of ops:  4
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
   33     3      > 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/vP47X
function name:  getURLs
number of ops:  26
compiled vars:  !0 = $regexa, !1 = $matches, !2 = $a, !3 = $regexno, !4 = $regexurl, !5 = $url_fiche
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   ASSIGN                                                   !0, '%2F%5C%3Ca%28.%2A%29%5C%3C%5C%2Fa%5C%3E%2F'
   38     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                                                 
   40     7        FETCH_DIM_R                                      ~9      !1, 1
          8        ASSIGN                                                   !2, ~9
   47     9        ASSIGN                                                   !3, '%2Fname%3D%22%28%5Cd%2B%29%22%2Fi'
   48    10        INIT_FCALL                                               'preg_match'
         11        SEND_VAR                                                 !3
         12        SEND_VAR                                                 !2
         13        SEND_REF                                                 !1
         14        DO_ICALL                                                 
   54    15        ASSIGN                                                   !4, '%2Fhref%3D%22%28%5CS%2B%29%22%2Fi'
   55    16        INIT_FCALL                                               'preg_match'
         17        SEND_VAR                                                 !4
         18        SEND_VAR                                                 !2
         19        SEND_REF                                                 !1
         20        DO_ICALL                                                 
   59    21        FETCH_DIM_R                                      ~15     !1, 1
         22        CONCAT                                           ~16     'http%3A%2F%2Fwww.kijiji.ca', ~15
         23        ASSIGN                                                   !5, ~16
   62    24      > RETURN                                                   !1
   63    25*     > 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/vP47X
function name:  __construct
number of ops:  4
compiled vars:  !0 = $a1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   69     0  E >   RECV                                             !0      
   71     1        ASSIGN_OBJ                                               'html'
          2        OP_DATA                                                  !0
   72     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/vP47X
function name:  getHMTL
number of ops:  21
compiled vars:  !0 = $regexatt, !1 = $matches, !2 = $a, !3 = $regexcontent, !4 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   76     0  E >   ASSIGN                                                   !0, '%2F%5C%3Ctable+class%3D%22ad-attributes%22%3E%28.%2A%29%5C%3C%5C%2Ftable%5C%3E%2F'
   77     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAR                                                 !0
          3        FETCH_OBJ_R                                      ~6      'html'
          4        SEND_VAL                                                 ~6
          5        SEND_REF                                                 !1
          6        DO_ICALL                                                 
   78     7        FETCH_DIM_R                                      ~8      !1, 1
          8        ASSIGN                                                   !2, ~8
   80     9        ASSIGN                                                   !3, '%2F%5C%3Cdiv+id%3D%22UserContent%22%3E%28.%2A%29%5C%3C%5C%2Fdiv%5C%3E%2F'
   81    10        INIT_FCALL                                               'preg_match'
         11        SEND_VAR                                                 !3
         12        FETCH_OBJ_R                                      ~11     'html'
         13        SEND_VAL                                                 ~11
         14        SEND_REF                                                 !1
         15        DO_ICALL                                                 
   82    16        FETCH_DIM_R                                      ~13     !1, 1
         17        ASSIGN                                                   !4, ~13
   84    18        CONCAT                                           ~15     !2, !4
         19      > RETURN                                                   ~15
   85    20*     > RETURN                                                   null

End of function gethmtl

End of class AdInfoExtractor.

Class HTMLReader:
Function gethmtl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vP47X
function name:  getHMTL
number of ops:  3
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   89     0  E >   RECV                                             !0      
   91     1      > RETURN                                                   'dhoaudg+od+oaeywgdoad+%3Ctable+class%3D%22ad-attributes%22%3Eyesser%3C%2Ftable%3E+dfdssd+%3Cdiv+id%3D%22UserContent%22%3Egood%3C%2Fdiv%3E+dfdfdf+df+df'
   92     2*     > RETURN                                                   null

End of function gethmtl

End of class HTMLReader.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.49 ms | 1400 KiB | 15 Q