php教程

ADD

PHP code

<?php
/*
 * Adds "value1" to "value2" and stores the result into "result".
 * opcode number: 1
 */
echo 2;
?>

PHP opcodes

Function name: (null)

Compiled variables: none

line#op fetchextreturn operands
60 ADD   ~0 1,2
 1 ECHO     ~0
72 RETURN     1

User Contributed Notes

jcastromail at yahoo dot es 07-Jan-2018 10:35
For you information
Using +0 for casting a string into a integer works but it generates a warning in php 7.1+

PHP 5.X:   "abc"+0 = 0
PHP 7.0:   "abc"+0 = 0
PHP 7.1:   "abc"+0 = 0 (Warning: A non-numeric value encountered in..)

The correct way (if you are using it for casting) is to do

PHP 7.1:   (int)"abc" = 0
hulupiao at sina dot cn 19-Jun-2017 09:17
$ php -v
PHP 7.1.5 (cli) (built: May 13 2017 13:30:32) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.5, Copyright (c) 1999-2017, by Zend Technologies
    with Xdebug v2.5.4, Copyright (c) 2002-2017, by Derick Rethans
--------------------------------
$ cat test.php
<?php
echo 1 + 2;
--------------------------------
$
php -dvld.active=1 test.php
Finding entry points
Branch analysis from position
: 0
Jump found
. (Code = 62) Position 1 = -2
filename
:       /data/test.php
function name:  (null)
number of ops3
compiled vars
none
line    
#* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  
2     0  E >   EXT_STMT
         1       
ECHO                                                     3
   4     2     
> RETURN                                                   1
fengdingbo at gmail dot com 14-Aug-2013 04:56
<?php
echo 1+2;
?>
qiufeng@ubuntu:~$ php -dvld.active=1 test.php
Finding entry points
Branch analysis from position: 0
Return found
filename:       /home/qiufeng/test.php
function name:  (null)
number of ops:  3
compiled vars:  none
line     # *  op                           fetch          ext  return  operands
---------------------------------------------------------------------------------
   2     0  >   ADD                                              ~0      1, 2
         1      ECHO                                                     ~0
   3     2    > RETURN                                                   1

branch: #  0; line:     2-    3; sop:     0; eop:     2
path #1: 0,

CopyRight © 2008-2022 verySource.Com All Rights reserved. 京ICP备17048824号-1 京公网安备:11010502034788