3v4l.org

run code in 300+ PHP versions simultaneously
<?php class AdsListExtractor { var $html = 0; function __construct($a1) { $html = $a1; } function getURLs() { $regexa = '/\<a(.*)\<\/a\>/'; preg_match($regexa, $html, $matches); $a = $matches[1]; // 1234 //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 { var $id = 0; function __construct($a1) { $id = $a1; } function getHMTL() { if ($id == 0) { echo $this->Id; return; } echo $id; return; } } //'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_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>"; $liste = new AdsListExtractor($html_liste); $ad_info = new AdInfoExtractor($liste[1]); echo $ad_info->getHMTL();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v8D76
function name:  (null)
number of ops:  16
compiled vars:  !0 = $url_liste, !1 = $html_liste, !2 = $liste, !3 = $ad_info
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   63     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'
   65     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'
   67     2        NEW                                              $6      'AdsListExtractor'
          3        SEND_VAR_EX                                              !1
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $6
   68     6        NEW                                              $9      'AdInfoExtractor'
          7        CHECK_FUNC_ARG                                           
          8        FETCH_DIM_FUNC_ARG                               $10     !2, 1
          9        SEND_FUNC_ARG                                            $10
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !3, $9
   70    12        INIT_METHOD_CALL                                         !3, 'getHMTL'
         13        DO_FCALL                                      0  $13     
         14        ECHO                                                     $13
         15      > RETURN                                                   1

Class AdsListExtractor:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v8D76
function name:  __construct
number of ops:  3
compiled vars:  !0 = $a1, !1 = $html
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        ASSIGN                                                   !1, !0
    9     2      > 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/v8D76
function name:  getURLs
number of ops:  26
compiled vars:  !0 = $regexa, !1 = $html, !2 = $matches, !3 = $a, !4 = $regexno, !5 = $regexurl, !6 = $url_fiche
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, '%2F%5C%3Ca%28.%2A%29%5C%3C%5C%2Fa%5C%3E%2F'
   14     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAR                                                 !0
          3        SEND_VAR                                                 !1
          4        SEND_REF                                                 !2
          5        DO_ICALL                                                 
   16     6        FETCH_DIM_R                                      ~9      !2, 1
          7        ASSIGN                                                   !3, ~9
   23     8        ASSIGN                                                   !4, '%2Fname%3D%22%28%5Cd%2B%29%22%2Fi'
   24     9        INIT_FCALL                                               'preg_match'
         10        SEND_VAR                                                 !4
         11        SEND_VAR                                                 !3
         12        SEND_REF                                                 !2
         13        DO_ICALL                                                 
   30    14        ASSIGN                                                   !5, '%2Fhref%3D%22%28%5CS%2B%29%22%2Fi'
   31    15        INIT_FCALL                                               'preg_match'
         16        SEND_VAR                                                 !5
         17        SEND_VAR                                                 !3
         18        SEND_REF                                                 !2
         19        DO_ICALL                                                 
   35    20        FETCH_DIM_R                                      ~15     !2, 1
         21        CONCAT                                           ~16     'http%3A%2F%2Fwww.kijiji.ca', ~15
         22        ASSIGN                                                   !6, ~16
   36    23        ECHO                                                     !6
   38    24      > RETURN                                                   !2
   39    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/v8D76
function name:  __construct
number of ops:  3
compiled vars:  !0 = $a1, !1 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
   47     1        ASSIGN                                                   !1, !0
   48     2      > RETURN                                                   null

End of function __construct

Function gethmtl:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 5
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v8D76
function name:  getHMTL
number of ops:  8
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E >   IS_EQUAL                                                 !0, 0
          1      > JMPZ                                                     ~1, ->5
   53     2    >   FETCH_OBJ_R                                      ~2      'Id'
          3        ECHO                                                     ~2
   54     4      > RETURN                                                   null
   56     5    >   ECHO                                                     !0
   57     6      > RETURN                                                   null
   58     7*     > RETURN                                                   null

End of function gethmtl

End of class AdInfoExtractor.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.75 ms | 1392 KiB | 15 Q