3v4l.org

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

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

End of function gethmtl

End of class AdInfoExtractor.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.26 ms | 1404 KiB | 16 Q