try to debug PHP code with openssl

I am trying to debug the following code. I am using try and catch block but still it doesn't show any error message. The code used to work fine in 5.3.8 version but after upgrade to 5.3.13 it stopped working. I turned on display_errors true but couldn't get error. I am getting "The website has a programming error" message. Could you please let me know any suggestions.

error_reporting(-1);
$conf['error_level'] = 2;
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);


    $SIZE = 32;
    $IV_SIZE = 16;
    $CIPHER = 'aes-256-ofb';  
    try {

         $secret = openssl_random_pseudo_bytes($SIZE);
       } 
    catch (Exception $e) {
             die ('Error occurred: ' . $e->getMessage());
         }

    $iv = openssl_random_pseudo_bytes($IV_SIZE);

    try {

        $first = openssl_encrypt( $_POST['first_name'], $CIPHER, $secret, FALSE, $iv);
       } 
    catch (Exception $e) 
    {
        die ('Error occurred: ' . $e->getMessage());
    }

Answers


Add this line before setting display_errors:

error_reporting(E_ALL);

My guess is it was just working in the earlier php version, but broke after the upgrade. I don't think the open SSL libraries throw exceptions, so wrapping it in try/catch blocks won't do anything.


Need Your Help