3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fromCamelCaseToUnderscores($str) { $str[0] = strtolower($str[0]); // Just in case first character is uppercase. $str = str_replace('ID', 'Id', $str); // Hack for the way CATS defies camelCase convention return preg_replace_callback('/([A-Z])/', function($char) { return '_' . strtolower($char[1]); }, $str); } var_dump(fromCamelCaseToUnderscores(null));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o50mS
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'fromcamelcasetounderscores'
          2        SEND_VAL                                                 null
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Function fromcamelcasetounderscores:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o50mS
function name:  fromCamelCaseToUnderscores
number of ops:  21
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'strtolower'
          2        FETCH_DIM_R                                      ~2      !0, 0
          3        SEND_VAL                                                 ~2
          4        DO_ICALL                                         $3      
          5        ASSIGN_DIM                                               !0, 0
          6        OP_DATA                                                  $3
    7     7        INIT_FCALL                                               'str_replace'
          8        SEND_VAL                                                 'ID'
          9        SEND_VAL                                                 'Id'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $4      
         12        ASSIGN                                                   !0, $4
    9    13        INIT_FCALL                                               'preg_replace_callback'
         14        SEND_VAL                                                 '%2F%28%5BA-Z%5D%29%2F'
         15        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fo50mS%3A9%240'
   12    16        SEND_VAL                                                 ~6
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $7      
         19      > RETURN                                                   $7
   13    20*     > RETURN                                                   null

End of function fromcamelcasetounderscores

Function %00%7Bclosure%7D%2Fin%2Fo50mS%3A9%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o50mS
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'strtolower'
          2        FETCH_DIM_R                                      ~1      !0, 1
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5        CONCAT                                           ~3      '_', $2
          6      > RETURN                                                   ~3
   12     7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fo50mS%3A9%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.32 ms | 1403 KiB | 22 Q