phpopcodelanguage-history

When was the STRLEN opcode introduced in PHP?


I was surprised while checking the opcodes generated by a PHP script, that unlike other string functions like str_pad(), strlen() is not a function call like it used to (if I'm not mistaken), but has a dedicated STRLEN opcode:

strlen($c);
str_pad($c, 2);
...

   8     4        STRLEN                                           ~7      !2

...

   9     6        INIT_FCALL                                               'str_pad'
         7        SEND_VAR                                                 !2
         8        SEND_VAL                                                 2
         9        DO_ICALL                                                 

https://3v4l.org/9QJQ7/vld#output

In which PHP version was this opcode introduced? I couldn't find this information anywhere.


Solution

  • The STRLEN opcode was added in PHP 7.0. Here's the commit that introduced it.

    There are a number of other functions which have dedicated opcodes; currently, these functions are: