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.
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:
is_null,is_bool,is_long,is_int,is_integer,is_float,is_double,is_real,is_string,is_array,is_object,is_resource)intval,floatval,doubleval,strval)definedchrandordcall_user_funcandcall_user_func_arrayin_arraycount(akasizeof)get_classget_called_classgettypefunc_get_argsandfunc_num_argsarray_slicearray_key_exists