3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class Pont { // $unite ne sert que dans la classe, on met cette propriété en privé. private string $unite = 'm²'; public float $longueur; public float $largeur; public function getSurface(): string { return ($this->longueur * $this->largeur) . $this->unite; // on renvoie l’unité en plus de la surface }} $towerBridge = new Pont; $towerBridge->longueur = 286.0; $towerBridge->largeur = 15.0; echo $towerBridge->getSurface();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ip786
function name:  (null)
number of ops:  11
compiled vars:  !0 = $towerBridge
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $1      'Pont'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   19     3        ASSIGN_OBJ                                               !0, 'longueur'
          4        OP_DATA                                                  286
   20     5        ASSIGN_OBJ                                               !0, 'largeur'
          6        OP_DATA                                                  15
   22     7        INIT_METHOD_CALL                                         !0, 'getSurface'
          8        DO_FCALL                                      0  $6      
          9        ECHO                                                     $6
         10      > RETURN                                                   1

Class Pont:
Function getsurface:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ip786
function name:  getSurface
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_OBJ_R                                      ~0      'longueur'
          1        FETCH_OBJ_R                                      ~1      'largeur'
          2        MUL                                              ~2      ~0, ~1
          3        FETCH_OBJ_R                                      ~3      'unite'
          4        CONCAT                                           ~4      ~2, ~3
          5        VERIFY_RETURN_TYPE                                       ~4
          6      > RETURN                                                   ~4
   16     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function getsurface

End of class Pont.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.19 ms | 1394 KiB | 13 Q