3v4l.org

run code in 300+ PHP versions simultaneously
<?php $url = 'http://stackoverflow.com/questions/7994340/how-can-i-get-image-from-url-in-php-or-jquery-or-in-both'; $data = file_get_contents($url); $dom = new DOMDocument; $dom->loadHTML($data); $img = $dom->getElementsByTagName('img'); foreach($img as $x){ echo $x->src; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/pG4hc
function name:  (null)
number of ops:  22
compiled vars:  !0 = $url, !1 = $data, !2 = $dom, !3 = $img, !4 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'http%3A%2F%2Fstackoverflow.com%2Fquestions%2F7994340%2Fhow-can-i-get-image-from-url-in-php-or-jquery-or-in-both'
    3     1        INIT_FCALL                                               'file_get_contents'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $6      
          4        ASSIGN                                                   !1, $6
    5     5        NEW                                              $8      'DOMDocument'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !2, $8
    6     8        INIT_METHOD_CALL                                         !2, 'loadHTML'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0          
    8    11        INIT_METHOD_CALL                                         !2, 'getElementsByTagName'
         12        SEND_VAL_EX                                              'img'
         13        DO_FCALL                                      0  $12     
         14        ASSIGN                                                   !3, $12
    9    15      > FE_RESET_R                                       $14     !3, ->20
         16    > > FE_FETCH_R                                               $14, !4, ->20
   10    17    >   FETCH_OBJ_R                                      ~15     !4, 'src'
         18        ECHO                                                     ~15
    9    19      > JMP                                                      ->16
         20    >   FE_FREE                                                  $14
   11    21      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.36 ms | 1395 KiB | 15 Q