3v4l.org

run code in 300+ PHP versions simultaneously
<?php const CheckOutPurchaseState = array( 0 => "New", // The partner site just negotiated a session but the Check-Out form hasn't been shown in a browser yet. 1 => "BeingProcessed", // The customer is going through the Check-Out wizard. 2 => "Completed", //The Check-Out has been successfully completed. 3 => "Error", // The Check-Out session has been canceled either by the user or due to an error. 4 => "WaitingForSignicat", // A redirect to Signicat website has been made and the customer hasn’t get redirected back to the original page yet. It purchases gets stuck it this state, a possible cause is that the page of the partner site that hosts the Check-Out form doesn't handle redirects correctly. 5 => "SessionTimedOut", // The session timed out or wasn’t even created for a long time after the purchase has been initialized. 6 => "WaitingForCardPayments", // A redirect to card payment provider has been made and the customer hasn't been redirected back to the original page yet. Same as with WaitingForSignicat state, if purchases gets stuck in this state, the host page might not be able to render itself repeatedly. 7 => "WaitingForBankId", //Waiting for response from BankId application. 8 => "Cancelled", //When merchant calls CancelPayment method and order is canceled. 9 => "WaitingForFinnishDirectPayment" //The customer has been redirected to a Finnish bank for a direct payment. ); function getPurchaseStateValue($purchaseStateName) { echo $purchaseStateName; echo print_r( CheckOutPurchaseState, true); if(in_array($purchaseStateName, CheckOutPurchaseState)) { return array_search($purchaseStateName,CheckOutPurchaseState); } else { //return the New state as default return array_search('New', CheckOutPurchaseState); } } echo getPurchaseStateValue('Complete');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ndQ4m
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CONST                                            'CheckOutPurchaseState', <array>
   33     1        INIT_FCALL                                               'getpurchasestatevalue'
          2        SEND_VAL                                                 'Complete'
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
          5      > RETURN                                                   1

Function getpurchasestatevalue:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ndQ4m
function name:  getPurchaseStateValue
number of ops:  28
compiled vars:  !0 = $purchaseStateName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        ECHO                                                     !0
   21     2        INIT_FCALL                                               'print_r'
          3        FETCH_CONSTANT                                   ~1      'CheckOutPurchaseState'
          4        SEND_VAL                                                 ~1
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                         $2      
          7        ECHO                                                     $2
   22     8        INIT_FCALL                                               'in_array'
          9        SEND_VAR                                                 !0
         10        FETCH_CONSTANT                                   ~3      'CheckOutPurchaseState'
         11        SEND_VAL                                                 ~3
         12        DO_ICALL                                         $4      
         13      > JMPZ                                                     $4, ->21
   24    14    >   INIT_FCALL                                               'array_search'
         15        SEND_VAR                                                 !0
         16        FETCH_CONSTANT                                   ~5      'CheckOutPurchaseState'
         17        SEND_VAL                                                 ~5
         18        DO_ICALL                                         $6      
         19      > RETURN                                                   $6
         20*       JMP                                                      ->27
   29    21    >   INIT_FCALL                                               'array_search'
         22        SEND_VAL                                                 'New'
         23        FETCH_CONSTANT                                   ~7      'CheckOutPurchaseState'
         24        SEND_VAL                                                 ~7
         25        DO_ICALL                                         $8      
         26      > RETURN                                                   $8
   31    27*     > RETURN                                                   null

End of function getpurchasestatevalue

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.06 ms | 1399 KiB | 20 Q