3v4l.org

run code in 300+ PHP versions simultaneously
<?php// User Public/Private Keys $private_key = 'private_key_user_id_QQKsTYtABdHd'; $public_key = 'public_key_user_id_v4dkuUg5pAeV'; // Data to be submitted $my_string = array( 'action' => 'api_register', 'first_name' => ".urlencode($first_name).", 'surname' => ".urlencode($surname).", 'user_password' => ".urlencode($user_password.)", 'user_password_repeat' => ".urlencode($user_password).", 'user_name' => ".urlencode($user_name).", 'signup_channel' => ".urlencode($signup_channel)." ); echo json_encode($my_string); // Generate content verification signature $signature = base64_encode(hash_hmac('sha1', $my_string, $private_key, TRUE)); $curl = curl_init(); if ( !$curl ) { print "Failed to initalise cURL object\n"; } else { $url ='https://www.casafina.com/api/user.php'; curl_setopt($ch, CURLOPT_CUSTOMREQUEST, array("signature" => $signature, "pubKey" => $public_key)); curl_setopt($ch, CURLOPT_POSTFIELDS, $my_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($my_string)) ); if ( !curl_setopt_array( $curl, $curl_opts ) ) { print "Unable to set properties on CURL object\n"; } else { $response = curl_exec( $curl ); $responseCode = curl_getinfo( $curl, CURLINFO_HTTP_CODE ); if ( is_bool( $response ) && $response == false ) { // Failed to make HTTP request to tracking URL echo 'Error from CURL in livefeed: "', curl_error( $curl ), '" ', var_export( curl_getinfo( $curl ), TRUE ); } else if ( ! ( $responseCode >= 200 && $responseCode <= 299 ) ) { // We got an HTTP response, but it was not successful print "Error: Tracking URL returned HTTP $responseCode\n"; } else { // All good print "Success, response was:\n"; echo var_export( $response ), "\n"; } } } curl_close( $curl ); // log the values $values[] = $response; $values[] = $responseCode; $values[] = $my_string; logResults($values, 'Casafina');
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.32, 7.2.29 - 7.2.33, 7.3.16 - 7.3.31, 7.4.3 - 7.4.25, 7.4.27 - 7.4.32, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<?php// User Public/Private Keys $private_key = 'private_key_user_id_QQKsTYtABdHd'; $public_key = 'public_key_user_id_v4dkuUg5pAeV'; // Data to be submitted $my_string = array( 'action' => 'api_register', 'first_name' => ".urlencode($first_name).", 'surname' => ".urlencode($surname).", 'user_password' => ".urlencode($user_password.)", 'user_password_repeat' => ".urlencode($user_password).", 'user_name' => ".urlencode($user_name).", 'signup_channel' => ".urlencode($signup_channel)." ); echo json_encode($my_string); // Generate content verification signature $signature = base64_encode(hash_hmac('sha1', $my_string, $private_key, TRUE)); $curl = curl_init(); if ( !$curl ) { print "Failed to initalise cURL object\n"; } else { $url ='https://www.casafina.com/api/user.php'; curl_setopt($ch, CURLOPT_CUSTOMREQUEST, array("signature" => $signature, "pubKey" => $public_key)); curl_setopt($ch, CURLOPT_POSTFIELDS, $my_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($my_string)) ); if ( !curl_setopt_array( $curl, $curl_opts ) ) { print "Unable to set properties on CURL object\n"; } else { $response = curl_exec( $curl ); $responseCode = curl_getinfo( $curl, CURLINFO_HTTP_CODE ); if ( is_bool( $response ) && $response == false ) { // Failed to make HTTP request to tracking URL echo 'Error from CURL in livefeed: "', curl_error( $curl ), '" ', var_export( curl_getinfo( $curl ), TRUE ); } else if ( ! ( $responseCode >= 200 && $responseCode <= 299 ) ) { // We got an HTTP response, but it was not successful print "Error: Tracking URL returned HTTP $responseCode\n"; } else { // All good print "Success, response was:\n"; echo var_export( $response ), "\n"; } } } curl_close( $curl ); // log the values $values[] = $response; $values[] = $responseCode; $values[] = $my_string; logResults($values, 'Casafina');
Output for 8.0.13
Parse error: syntax error, unexpected variable "$private_key" in /in/RHHFC on line 2
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.26, 7.4.33
Parse error: syntax error, unexpected '$private_key' (T_VARIABLE) in /in/RHHFC on line 2
Process exited with code 255.

preferences:
162.4 ms | 401 KiB | 203 Q