0

Suppose I have the following array

$options = array(
            PDO::ATTR_PERSISTENT => true,
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
        );

When I do var_dump($options)

array(2) { [12]=> bool(true) [3]=> int(2) }

However I want the predefined constant to display like PDO::ATTR_PERSISTENT not as 12

user2650277
  • 6,289
  • 17
  • 63
  • 132
  • That’s not possible. Imagine instead of constants, you were using variables – then you would not expect the var_dump output to show the variable name either, but the only thing that makes sense – the value. – CBroe Apr 09 '16 at 06:17
  • 1) Why? 2) The constants just correspond to some value which you see in the output – Rizier123 Apr 09 '16 at 06:18
  • Why can't you just later call $options[PDO::ATTR_PERSISTENT] (or any other key that is available in the `$options`)? It will evaluate to $options[12], and return `true`. – Eihwaz Apr 09 '16 at 06:23
  • maybe useful? [Can I get CONST's defined on a PHP class?](http://stackoverflow.com/questions/956401/can-i-get-consts-defined-on-a-php-class). e.g. : `$refl = new ReflectionClass('PDO'); print_r($refl->getConstants());` . You may need to filter them to limit them to the ones you actually want but that would be easy to do? – Ryan Vincent Apr 09 '16 at 10:30

0 Answers0