3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Parameter Example $data = array('post_id'=>'12345','post_title'=>'A Blog post'); $target = 'single tocken id or topic name'; or $target = array('token1','token2','...'); // up to 1000 in one request */ function sendMessage($data, $target){ //FCM api URL $url = 'https://fcm.googleapis.com/fcm/send'; //api_key available in Firebase Console -> Project Settings -> CLOUD MESSAGING -> Server key $server_key = 'AIzaSyDdGQuWaop0NoJd09t4DKLi-Vdt7hQJ0pU'; $fields = array(); $fields['data'] = $data; if(is_array($target)){ $fields['registration_ids'] = $target; }else{ $fields['to'] = $target; } //header with content_type api key $headers = array( 'Content-Type:application/json', 'Authorization:key='.$server_key ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('FCM Send Error: ' . curl_error($ch)); } curl_close($ch); return $result; } echo sendMessage(array('message' => 'lol', 'post_title' => 'LOL'), '/topics/news'); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v00fv
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   INIT_FCALL                                               'sendmessage'
          1        SEND_VAL                                                 <array>
          2        SEND_VAL                                                 '%2Ftopics%2Fnews'
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
   46     5      > RETURN                                                   1

Function sendmessage:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 72, Position 2 = 77
Branch analysis from position: 72
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 77
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 72, Position 2 = 77
Branch analysis from position: 72
Branch analysis from position: 77
filename:       /in/v00fv
function name:  sendMessage
number of ops:  82
compiled vars:  !0 = $data, !1 = $target, !2 = $url, !3 = $server_key, !4 = $fields, !5 = $headers, !6 = $ch, !7 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        ASSIGN                                                   !2, 'https%3A%2F%2Ffcm.googleapis.com%2Ffcm%2Fsend'
   13     3        ASSIGN                                                   !3, 'AIzaSyDdGQuWaop0NoJd09t4DKLi-Vdt7hQJ0pU'
   15     4        ASSIGN                                                   !4, <array>
   16     5        ASSIGN_DIM                                               !4, 'data'
          6        OP_DATA                                                  !0
   17     7        TYPE_CHECK                                  128          !1
          8      > JMPZ                                                     ~12, ->12
   18     9    >   ASSIGN_DIM                                               !4, 'registration_ids'
         10        OP_DATA                                                  !1
         11      > JMP                                                      ->14
   20    12    >   ASSIGN_DIM                                               !4, 'to'
         13        OP_DATA                                                  !1
   24    14    >   INIT_ARRAY                                       ~15     'Content-Type%3Aapplication%2Fjson'
   25    15        CONCAT                                           ~16     'Authorization%3Akey%3D', !3
         16        ADD_ARRAY_ELEMENT                                ~15     ~16
   23    17        ASSIGN                                                   !5, ~15
   28    18        INIT_FCALL_BY_NAME                                       'curl_init'
         19        DO_FCALL                                      0  $18     
         20        ASSIGN                                                   !6, $18
   29    21        INIT_FCALL_BY_NAME                                       'curl_setopt'
         22        SEND_VAR_EX                                              !6
         23        FETCH_CONSTANT                                   ~20     'CURLOPT_URL'
         24        SEND_VAL_EX                                              ~20
         25        SEND_VAR_EX                                              !2
         26        DO_FCALL                                      0          
   30    27        INIT_FCALL_BY_NAME                                       'curl_setopt'
         28        SEND_VAR_EX                                              !6
         29        FETCH_CONSTANT                                   ~22     'CURLOPT_POST'
         30        SEND_VAL_EX                                              ~22
         31        SEND_VAL_EX                                              <true>
         32        DO_FCALL                                      0          
   31    33        INIT_FCALL_BY_NAME                                       'curl_setopt'
         34        SEND_VAR_EX                                              !6
         35        FETCH_CONSTANT                                   ~24     'CURLOPT_HTTPHEADER'
         36        SEND_VAL_EX                                              ~24
         37        SEND_VAR_EX                                              !5
         38        DO_FCALL                                      0          
   32    39        INIT_FCALL_BY_NAME                                       'curl_setopt'
         40        SEND_VAR_EX                                              !6
         41        FETCH_CONSTANT                                   ~26     'CURLOPT_RETURNTRANSFER'
         42        SEND_VAL_EX                                              ~26
         43        SEND_VAL_EX                                              <true>
         44        DO_FCALL                                      0          
   33    45        INIT_FCALL_BY_NAME                                       'curl_setopt'
         46        SEND_VAR_EX                                              !6
         47        FETCH_CONSTANT                                   ~28     'CURLOPT_SSL_VERIFYHOST'
         48        SEND_VAL_EX                                              ~28
         49        SEND_VAL_EX                                              0
         50        DO_FCALL                                      0          
   34    51        INIT_FCALL_BY_NAME                                       'curl_setopt'
         52        SEND_VAR_EX                                              !6
         53        FETCH_CONSTANT                                   ~30     'CURLOPT_SSL_VERIFYPEER'
         54        SEND_VAL_EX                                              ~30
         55        SEND_VAL_EX                                              <false>
         56        DO_FCALL                                      0          
   35    57        INIT_FCALL_BY_NAME                                       'curl_setopt'
         58        SEND_VAR_EX                                              !6
         59        FETCH_CONSTANT                                   ~32     'CURLOPT_POSTFIELDS'
         60        SEND_VAL_EX                                              ~32
         61        INIT_FCALL                                               'json_encode'
         62        SEND_VAR                                                 !4
         63        DO_ICALL                                         $33     
         64        SEND_VAR_NO_REF_EX                                       $33
         65        DO_FCALL                                      0          
   36    66        INIT_FCALL_BY_NAME                                       'curl_exec'
         67        SEND_VAR_EX                                              !6
         68        DO_FCALL                                      0  $35     
         69        ASSIGN                                                   !7, $35
   37    70        TYPE_CHECK                                    4          !7
         71      > JMPZ                                                     ~37, ->77
   38    72    >   INIT_FCALL_BY_NAME                                       'curl_error'
         73        SEND_VAR_EX                                              !6
         74        DO_FCALL                                      0  $38     
         75        CONCAT                                           ~39     'FCM+Send+Error%3A+', $38
         76      > EXIT                                                     ~39
   40    77    >   INIT_FCALL_BY_NAME                                       'curl_close'
         78        SEND_VAR_EX                                              !6
         79        DO_FCALL                                      0          
   41    80      > RETURN                                                   !7
   42    81*     > RETURN                                                   null

End of function sendmessage

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.9 ms | 1407 KiB | 16 Q