什么时候用PHP引入STRLEN操作码?

问题描述 投票:0回答:1

检查PHP脚本生成的操作码时,我感到很惊讶,与str_pad()等其他字符串函数不同,strlen()不是像以前那样的函数调用(如果我没有记错的话),但是有一个专用的STRLEN操作码:

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

这个操作码是在哪个PHP版本中引入的?我无法在任何地方找到这些信息。

php opcode language-history
1个回答
5
投票

STRLEN操作码是在PHP 7.0中添加的。 Here's the commit that introduced it.

还有许多具有专用操作码的其他功能;目前,这些功能是:

  • 某些类型检查功能(is_nullis_boolis_longis_intis_integeris_floatis_doubleis_realis_stringis_arrayis_objectis_resource
  • 某些类型转换函数(intvalfloatvaldoublevalstrval
  • defined
  • chrord
  • call_user_funccall_user_func_array
  • in_array
  • count(又名sizeof
  • get_class
  • get_called_class
  • gettype
  • func_get_argsfunc_num_args
  • array_slice
  • array_key_exists
© www.soinside.com 2019 - 2024. All rights reserved.