3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Install this pear extention on linux by doing: $ pear channel-discover phpquery-pear.appspot.com $ pear install phpquery/phpQuery */ require('phpQuery.php'); /** * Gets the server that a player has joined * @param string $username The username of the player * @return array An array that consists of: success, title, url and errorCode */ $username = "SoL0vex" ; function getJoinedServer ($username) { $curl = curl_init("http://battlelog.battlefield.com/bf3/user/$username"); curl_setopt($curl, CURLOPT_FAILONERROR, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_ENCODING, 'gzip'); curl_setopt($curl, CURLOPT_TIMEOUT, 30); $doc = phpQuery::newDocument(curl_exec($curl)); phpQuery::selectDocument($doc); $li = pq('.common-playing-link a'); if (pq($li)->attr('href')) { return array('success' => true, 'title' => pq($li)->attr('title'), 'url' => 'http://battlelog.battlefield.com' . pq($li)->attr('href')); } else { return array('success' => false, 'errorCode' => 1); } curl_close($curl); } // Measure time $mtime = microtime(); $mtime = explode(' ',$mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; // Get joined server $result = getJoinedServer((isset($_GET['user']) ? $_GET['user'] : 'diegorod')); if($result['success']) { echo "<a href='${result['url']}'>${result['title']}</a>"; } elseif ($result['errorCode'] === 1) { echo 'User not playing'; } // Stop measuring time $mtime = microtime(); $mtime = explode(' ',$mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); // Output execution time echo '<br>This page was created in '.$totaltime.' seconds'; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 38
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 42
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 38
Branch analysis from position: 29
Branch analysis from position: 38
filename:       /in/8r7rg
function name:  (null)
number of ops:  61
compiled vars:  !0 = $username, !1 = $mtime, !2 = $starttime, !3 = $result, !4 = $endtime, !5 = $totaltime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INCLUDE_OR_EVAL                                          'phpQuery.php', REQUIRE
   12     1        ASSIGN                                                   !0, 'SoL0vex'
   33     2        INIT_FCALL                                               'microtime'
          3        DO_ICALL                                         $8      
          4        ASSIGN                                                   !1, $8
   34     5        INIT_FCALL                                               'explode'
          6        SEND_VAL                                                 '+'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $10     
          9        ASSIGN                                                   !1, $10
   35    10        FETCH_DIM_R                                      ~12     !1, 1
         11        FETCH_DIM_R                                      ~13     !1, 0
         12        ADD                                              ~14     ~12, ~13
         13        ASSIGN                                                   !1, ~14
   36    14        ASSIGN                                                   !2, !1
   38    15        INIT_FCALL                                               'getjoinedserver'
         16        FETCH_IS                                         ~17     '_GET'
         17        ISSET_ISEMPTY_DIM_OBJ                         0          ~17, 'user'
         18      > JMPZ                                                     ~18, ->23
         19    >   FETCH_R                      global              ~19     '_GET'
         20        FETCH_DIM_R                                      ~20     ~19, 'user'
         21        QM_ASSIGN                                        ~21     ~20
         22      > JMP                                                      ->24
         23    >   QM_ASSIGN                                        ~21     'diegorod'
         24    >   SEND_VAL                                                 ~21
         25        DO_FCALL                                      0  $22     
         26        ASSIGN                                                   !3, $22
   39    27        FETCH_DIM_R                                      ~24     !3, 'success'
         28      > JMPZ                                                     ~24, ->38
   40    29    >   ROPE_INIT                                     5  ~28     '%3Ca+href%3D%27'
         30        FETCH_DIM_R                                      ~25     !3, 'url'
         31        ROPE_ADD                                      1  ~28     ~28, ~25
         32        ROPE_ADD                                      2  ~28     ~28, '%27%3E'
         33        FETCH_DIM_R                                      ~26     !3, 'title'
         34        ROPE_ADD                                      3  ~28     ~28, ~26
         35        ROPE_END                                      4  ~27     ~28, '%3C%2Fa%3E'
         36        ECHO                                                     ~27
   39    37      > JMP                                                      ->42
   41    38    >   FETCH_DIM_R                                      ~31     !3, 'errorCode'
         39        IS_IDENTICAL                                             ~31, 1
         40      > JMPZ                                                     ~32, ->42
   42    41    >   ECHO                                                     'User+not+playing'
   45    42    >   INIT_FCALL                                               'microtime'
         43        DO_ICALL                                         $33     
         44        ASSIGN                                                   !1, $33
   46    45        INIT_FCALL                                               'explode'
         46        SEND_VAL                                                 '+'
         47        SEND_VAR                                                 !1
         48        DO_ICALL                                         $35     
         49        ASSIGN                                                   !1, $35
   47    50        FETCH_DIM_R                                      ~37     !1, 1
         51        FETCH_DIM_R                                      ~38     !1, 0
         52        ADD                                              ~39     ~37, ~38
         53        ASSIGN                                                   !1, ~39
   48    54        ASSIGN                                                   !4, !1
   49    55        SUB                                              ~42     !4, !2
         56        ASSIGN                                                   !5, ~42
   51    57        CONCAT                                           ~44     '%3Cbr%3EThis+page+was+created+in+', !5
         58        CONCAT                                           ~45     ~44, '+seconds'
         59        ECHO                                                     ~45
   52    60      > RETURN                                                   1

Function getjoinedserver:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 70, Position 2 = 88
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 88
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8r7rg
function name:  getJoinedServer
number of ops:  93
compiled vars:  !0 = $username, !1 = $curl, !2 = $doc, !3 = $li
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        INIT_FCALL_BY_NAME                                       'curl_init'
          2        NOP                                                      
          3        FAST_CONCAT                                      ~4      'http%3A%2F%2Fbattlelog.battlefield.com%2Fbf3%2Fuser%2F', !0
          4        SEND_VAL_EX                                              ~4
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !1, $5
   15     7        INIT_FCALL_BY_NAME                                       'curl_setopt'
          8        SEND_VAR_EX                                              !1
          9        FETCH_CONSTANT                                   ~7      'CURLOPT_FAILONERROR'
         10        SEND_VAL_EX                                              ~7
         11        SEND_VAL_EX                                              <true>
         12        DO_FCALL                                      0          
   16    13        INIT_FCALL_BY_NAME                                       'curl_setopt'
         14        SEND_VAR_EX                                              !1
         15        FETCH_CONSTANT                                   ~9      'CURLOPT_FOLLOWLOCATION'
         16        SEND_VAL_EX                                              ~9
         17        SEND_VAL_EX                                              <true>
         18        DO_FCALL                                      0          
   17    19        INIT_FCALL_BY_NAME                                       'curl_setopt'
         20        SEND_VAR_EX                                              !1
         21        FETCH_CONSTANT                                   ~11     'CURLOPT_RETURNTRANSFER'
         22        SEND_VAL_EX                                              ~11
         23        SEND_VAL_EX                                              <true>
         24        DO_FCALL                                      0          
   18    25        INIT_FCALL_BY_NAME                                       'curl_setopt'
         26        SEND_VAR_EX                                              !1
         27        FETCH_CONSTANT                                   ~13     'CURLOPT_SSL_VERIFYHOST'
         28        SEND_VAL_EX                                              ~13
         29        SEND_VAL_EX                                              <false>
         30        DO_FCALL                                      0          
   19    31        INIT_FCALL_BY_NAME                                       'curl_setopt'
         32        SEND_VAR_EX                                              !1
         33        FETCH_CONSTANT                                   ~15     'CURLOPT_SSL_VERIFYPEER'
         34        SEND_VAL_EX                                              ~15
         35        SEND_VAL_EX                                              <false>
         36        DO_FCALL                                      0          
   20    37        INIT_FCALL_BY_NAME                                       'curl_setopt'
         38        SEND_VAR_EX                                              !1
         39        FETCH_CONSTANT                                   ~17     'CURLOPT_ENCODING'
         40        SEND_VAL_EX                                              ~17
         41        SEND_VAL_EX                                              'gzip'
         42        DO_FCALL                                      0          
   21    43        INIT_FCALL_BY_NAME                                       'curl_setopt'
         44        SEND_VAR_EX                                              !1
         45        FETCH_CONSTANT                                   ~19     'CURLOPT_TIMEOUT'
         46        SEND_VAL_EX                                              ~19
         47        SEND_VAL_EX                                              30
         48        DO_FCALL                                      0          
   22    49        INIT_STATIC_METHOD_CALL                                  'phpQuery', 'newDocument'
         50        INIT_FCALL_BY_NAME                                       'curl_exec'
         51        SEND_VAR_EX                                              !1
         52        DO_FCALL                                      0  $21     
         53        SEND_VAR_NO_REF_EX                                       $21
         54        DO_FCALL                                      0  $22     
         55        ASSIGN                                                   !2, $22
   23    56        INIT_STATIC_METHOD_CALL                                  'phpQuery', 'selectDocument'
         57        SEND_VAR_EX                                              !2
         58        DO_FCALL                                      0          
   24    59        INIT_FCALL_BY_NAME                                       'pq'
         60        SEND_VAL_EX                                              '.common-playing-link+a'
         61        DO_FCALL                                      0  $25     
         62        ASSIGN                                                   !3, $25
   25    63        INIT_FCALL_BY_NAME                                       'pq'
         64        SEND_VAR_EX                                              !3
         65        DO_FCALL                                      0  $27     
         66        INIT_METHOD_CALL                                         $27, 'attr'
         67        SEND_VAL_EX                                              'href'
         68        DO_FCALL                                      0  $28     
         69      > JMPZ                                                     $28, ->88
   26    70    >   INIT_ARRAY                                       ~29     <true>, 'success'
         71        INIT_FCALL_BY_NAME                                       'pq'
         72        SEND_VAR_EX                                              !3
         73        DO_FCALL                                      0  $30     
         74        INIT_METHOD_CALL                                         $30, 'attr'
         75        SEND_VAL_EX                                              'title'
         76        DO_FCALL                                      0  $31     
         77        ADD_ARRAY_ELEMENT                                ~29     $31, 'title'
         78        INIT_FCALL_BY_NAME                                       'pq'
         79        SEND_VAR_EX                                              !3
         80        DO_FCALL                                      0  $32     
         81        INIT_METHOD_CALL                                         $32, 'attr'
         82        SEND_VAL_EX                                              'href'
         83        DO_FCALL                                      0  $33     
         84        CONCAT                                           ~34     'http%3A%2F%2Fbattlelog.battlefield.com', $33
         85        ADD_ARRAY_ELEMENT                                ~29     ~34, 'url'
         86      > RETURN                                                   ~29
   25    87*       JMP                                                      ->89
   28    88    > > RETURN                                                   <array>
   30    89*       INIT_FCALL_BY_NAME                                       'curl_close'
         90*       SEND_VAR_EX                                              !1
         91*       DO_FCALL                                      0          
   31    92*     > RETURN                                                   null

End of function getjoinedserver

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.18 ms | 1476 KiB | 16 Q