How do I examine defined constants in PHP?

后端 未结 4 2144
走了就别回头了
走了就别回头了 2020-12-06 05:40

I\'m stepping through the source code of CodeIgniter with Xdebug in NetBeans and I\'m looking for a way to see defined constants as they are defined. If it\'s not possible,

4条回答
  •  死守一世寂寞
    2020-12-06 06:05

    This kind of practice I use is quite decent as it shows only custom/user created constants.

    print_r(var_export(get_defined_constants(true)['user'], true));
    

    Wrap this within pre tags or just view source and you'll get very nice array of all the stuff You defined.

    Note that this is not going to work with php 5.3.* where in 5.4.* it outputs fine.

    In earlier versions of php, get_defined_constants() must be assigned to a variable first, before output. Something like this.

    $gdc = get_defined_constants(true);
    print_r( var_export($gdc['user'], true) );
    

提交回复
热议问题