3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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');
based on OnKZS
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0alpha1
CompleteArray ( [0] => New [1] => BeingProcessed [2] => Completed [3] => Error [4] => WaitingForSignicat [5] => SessionTimedOut [6] => WaitingForCardPayments [7] => WaitingForBankId [8] => Cancelled [9] => WaitingForFinnishDirectPayment ) 0
Output for hhvm-3.15.4
Warning: Constants may only evaluate to scalar values in /in/ndQ4m on line 14 Complete Notice: Use of undefined constant CheckOutPurchaseState - assumed 'CheckOutPurchaseState' in /in/ndQ4m on line 21 CheckOutPurchaseState Notice: Use of undefined constant CheckOutPurchaseState - assumed 'CheckOutPurchaseState' in /in/ndQ4m on line 22 Warning: in_array() expects parameter 2 to be an array or collection in /in/ndQ4m on line 22 Notice: Use of undefined constant CheckOutPurchaseState - assumed 'CheckOutPurchaseState' in /in/ndQ4m on line 29 Warning: array_search() expects parameter 2 to be an array or collection in /in/ndQ4m on line 29