3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Shape { abstract protected function getArea(); public function toStringArea(){ return "The area of the " . get_called_class() . " is ".$this->getArea() . "\n"; } public function toStringPerimeter(){ return "The perimeter of the " . get_called_class() . " is ".$this->getPerimeter() . "\n"; } } class Rectangle extends Shape{ private $l; private $b; public function __construct($l,$b) { $this->l=$l; $this->b=$b; } protected function getArea(){ return $this->l * $this->b; } protected function getPerimeter(){ return 2 * $this->l + 2 * $this->b; } } class Triangle extends Shape{ private $l; private $b; public function __construct($l,$b) { $this->l=$l; $this->b=$b; } protected function getArea(){ return $this->l * $this->b * 0.5; } protected function getPerimeter(){ return $this->l + $this->b + sqrt($this->l * $this->l + $this->b * $this->l); } } class Circle extends Shape{ private $r; public function __construct($r) { $this->r=$r; } protected function getArea(){ return $this->r*$this->r*3.14; } protected function getPerimeter(){ return $this->r*2*3.14; } } echo' <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery Show Hide Using Selectbox</title> <style type="text/css"> .box{ padding: 20px; display: none; margin-top: 20px; border: 1px solid #000; } .red{ background: #ff0000; } .green{ background: #00ff00; } .blue{ background: #0000ff; } </style> <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("select").change(function(){ $( "select option:selected").each(function(){ if($(this).attr("value")=="red"){ $(".box").hide(); $(".red").show(); alert("Bam!"); } if($(this).attr("value")=="green"){ $(".box").hide(); $(".green").show(); } if($(this).attr("value")=="blue"){ $(".box").hide(); $(".blue").show(); } }); }).change(); }); </script> </head> <body> <div> <select> <option>Choose Color</option> <option value="red">Red</option> <option value="green">Green</option> <option value="blue">Blue</option> </select> </div> <div class="red box">You have selected <strong>red option</strong> so i am here</div> <div class="green box">You have selected <strong>green option</strong> so i am here</div> <div class="blue box">You have selected <strong>blue option</strong> so i am here</div> '; echo '<p>'; $r = new Rectangle(5, 4); echo $r->toStringArea() . "<br>"; echo $r->toStringPerimeter() . "<p>"; $c = new Circle(10); echo $c->toStringArea() . "<br>"; echo $c->toStringPerimeter() . "<p>"; $t = new Triangle(5, 4); echo $t->toStringArea() . "<br>"; echo $t->toStringPerimeter() . "<p>"; echo ' </body> </html> ';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  (null)
number of ops:  42
compiled vars:  !0 = $r, !1 = $c, !2 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   68     0  E >   ECHO                                                     '%0A%3C%21DOCTYPE+html%3E%0A%3Chtml+lang%3D%22en%22%3E%0A%3Chead%3E%0A%3Cmeta+charset%3D%22utf-8%22%3E%0A%3Ctitle%3EjQuery+Show+Hide+Using+Selectbox%3C%2Ftitle%3E%0A%3Cstyle+type%3D%22text%2Fcss%22%3E%0A++++.box%7B%0A++++++++padding%3A+20px%3B%0A++++++++display%3A+none%3B%0A++++++++margin-top%3A+20px%3B%0A++++++++border%3A+1px+solid+%23000%3B%0A++++%7D%0A++++.red%7B+background%3A+%23ff0000%3B+%7D%0A++++.green%7B+background%3A+%2300ff00%3B+%7D%0A++++.blue%7B+background%3A+%230000ff%3B+%7D%0A%3C%2Fstyle%3E%0A%3Cscript+type%3D%22text%2Fjavascript%22+src%3D%22http%3A%2F%2Fcode.jquery.com%2Fjquery.min.js%22%3E%3C%2Fscript%3E%0A%3Cscript+type%3D%22text%2Fjavascript%22%3E%0A++++%24%28document%29.ready%28function%28%29%7B%0A++++++++%24%28%22select%22%29.change%28function%28%29%7B%0A++++++++++++%24%28+%22select+option%3Aselected%22%29.each%28function%28%29%7B%0A++++++++++++++++if%28%24%28this%29.attr%28%22value%22%29%3D%3D%22red%22%29%7B%0A++++++++++++++++++++%24%28%22.box%22%29.hide%28%29%3B%0A++++++++++++++++++++%24%28%22.red%22%29.show%28%29%3B%0A%09%09%09%09%09alert%28%22Bam%21%22%29%3B%0A++++++++++++++++%7D%0A++++++++++++++++if%28%24%28this%29.attr%28%22value%22%29%3D%3D%22green%22%29%7B%0A++++++++++++++++++++%24%28%22.box%22%29.hide%28%29%3B%0A++++++++++++++++++++%24%28%22.green%22%29.show%28%29%3B%0A++++++++++++++++%7D%0A++++++++++++++++if%28%24%28this%29.attr%28%22value%22%29%3D%3D%22blue%22%29%7B%0A++++++++++++++++++++%24%28%22.box%22%29.hide%28%29%3B%0A++++++++++++++++++++%24%28%22.blue%22%29.show%28%29%3B%0A++++++++++++++++%7D%0A++++++++++++%7D%29%3B%0A++++++++%7D%29.change%28%29%3B%0A++++%7D%29%3B%0A%3C%2Fscript%3E%0A%3C%2Fhead%3E%0A%3Cbody%3E%0A++++%3Cdiv%3E%0A++++++++%3Cselect%3E%0A++++++++++++%3Coption%3EChoose+Color%3C%2Foption%3E%0A++++++++++++%3Coption+value%3D%22red%22%3ERed%3C%2Foption%3E%0A++++++++++++%3Coption+value%3D%22green%22%3EGreen%3C%2Foption%3E%0A++++++++++++%3Coption+value%3D%22blue%22%3EBlue%3C%2Foption%3E%0A++++++++%3C%2Fselect%3E%0A++++%3C%2Fdiv%3E%0A++++%3Cdiv+class%3D%22red+box%22%3EYou+have+selected+%3Cstrong%3Ered+option%3C%2Fstrong%3E+so+i+am+here%3C%2Fdiv%3E%0A++++%3Cdiv+class%3D%22green+box%22%3EYou+have+selected+%3Cstrong%3Egreen+option%3C%2Fstrong%3E+so+i+am+here%3C%2Fdiv%3E%0A++++%3Cdiv+class%3D%22blue+box%22%3EYou+have+selected+%3Cstrong%3Eblue+option%3C%2Fstrong%3E+so+i+am+here%3C%2Fdiv%3E%0A'
  122     1        ECHO                                                     '%3Cp%3E'
  124     2        NEW                                              $3      'Rectangle'
          3        SEND_VAL_EX                                              5
          4        SEND_VAL_EX                                              4
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $3
  125     7        INIT_METHOD_CALL                                         !0, 'toStringArea'
          8        DO_FCALL                                      0  $6      
          9        CONCAT                                           ~7      $6, '%3Cbr%3E'
         10        ECHO                                                     ~7
  126    11        INIT_METHOD_CALL                                         !0, 'toStringPerimeter'
         12        DO_FCALL                                      0  $8      
         13        CONCAT                                           ~9      $8, '%3Cp%3E'
         14        ECHO                                                     ~9
  128    15        NEW                                              $10     'Circle'
         16        SEND_VAL_EX                                              10
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !1, $10
  129    19        INIT_METHOD_CALL                                         !1, 'toStringArea'
         20        DO_FCALL                                      0  $13     
         21        CONCAT                                           ~14     $13, '%3Cbr%3E'
         22        ECHO                                                     ~14
  130    23        INIT_METHOD_CALL                                         !1, 'toStringPerimeter'
         24        DO_FCALL                                      0  $15     
         25        CONCAT                                           ~16     $15, '%3Cp%3E'
         26        ECHO                                                     ~16
  132    27        NEW                                              $17     'Triangle'
         28        SEND_VAL_EX                                              5
         29        SEND_VAL_EX                                              4
         30        DO_FCALL                                      0          
         31        ASSIGN                                                   !2, $17
  133    32        INIT_METHOD_CALL                                         !2, 'toStringArea'
         33        DO_FCALL                                      0  $20     
         34        CONCAT                                           ~21     $20, '%3Cbr%3E'
         35        ECHO                                                     ~21
  134    36        INIT_METHOD_CALL                                         !2, 'toStringPerimeter'
         37        DO_FCALL                                      0  $22     
         38        CONCAT                                           ~23     $22, '%3Cp%3E'
         39        ECHO                                                     ~23
  136    40        ECHO                                                     '%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E++++++++++++++++++++++++++++++++%09%09'
  138    41      > RETURN                                                   1

Class Shape:
Function getarea:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  getArea
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E > > RETURN                                                   null

End of function getarea

Function tostringarea:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  toStringArea
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   GET_CALLED_CLASS                                 ~0      
          1        CONCAT                                           ~1      'The+area+of+the+', ~0
          2        CONCAT                                           ~2      ~1, '+is+'
          3        INIT_METHOD_CALL                                         'getArea'
          4        DO_FCALL                                      0  $3      
          5        CONCAT                                           ~4      ~2, $3
          6        CONCAT                                           ~5      ~4, '%0A'
          7      > RETURN                                                   ~5
    7     8*     > RETURN                                                   null

End of function tostringarea

Function tostringperimeter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  toStringPerimeter
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   GET_CALLED_CLASS                                 ~0      
          1        CONCAT                                           ~1      'The+perimeter+of+the+', ~0
          2        CONCAT                                           ~2      ~1, '+is+'
          3        INIT_METHOD_CALL                                         'getPerimeter'
          4        DO_FCALL                                      0  $3      
          5        CONCAT                                           ~4      ~2, $3
          6        CONCAT                                           ~5      ~4, '%0A'
          7      > RETURN                                                   ~5
   11     8*     > RETURN                                                   null

End of function tostringperimeter

End of class Shape.

Class Rectangle:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  __construct
number of ops:  7
compiled vars:  !0 = $l, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        ASSIGN_OBJ                                               'l'
          3        OP_DATA                                                  !0
   20     4        ASSIGN_OBJ                                               'b'
          5        OP_DATA                                                  !1
   21     6      > RETURN                                                   null

End of function __construct

Function getarea:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  getArea
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   FETCH_OBJ_R                                      ~0      'l'
          1        FETCH_OBJ_R                                      ~1      'b'
          2        MUL                                              ~2      ~0, ~1
          3      > RETURN                                                   ~2
   25     4*     > RETURN                                                   null

End of function getarea

Function getperimeter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  getPerimeter
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   FETCH_OBJ_R                                      ~0      'l'
          1        MUL                                              ~1      ~0, 2
          2        FETCH_OBJ_R                                      ~2      'b'
          3        MUL                                              ~3      ~2, 2
          4        ADD                                              ~4      ~1, ~3
          5      > RETURN                                                   ~4
   29     6*     > RETURN                                                   null

End of function getperimeter

Function tostringarea:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  toStringArea
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   GET_CALLED_CLASS                                 ~0      
          1        CONCAT                                           ~1      'The+area+of+the+', ~0
          2        CONCAT                                           ~2      ~1, '+is+'
          3        INIT_METHOD_CALL                                         'getArea'
          4        DO_FCALL                                      0  $3      
          5        CONCAT                                           ~4      ~2, $3
          6        CONCAT                                           ~5      ~4, '%0A'
          7      > RETURN                                                   ~5
    7     8*     > RETURN                                                   null

End of function tostringarea

Function tostringperimeter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  toStringPerimeter
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   GET_CALLED_CLASS                                 ~0      
          1        CONCAT                                           ~1      'The+perimeter+of+the+', ~0
          2        CONCAT                                           ~2      ~1, '+is+'
          3        INIT_METHOD_CALL                                         'getPerimeter'
          4        DO_FCALL                                      0  $3      
          5        CONCAT                                           ~4      ~2, $3
          6        CONCAT                                           ~5      ~4, '%0A'
          7      > RETURN                                                   ~5
   11     8*     > RETURN                                                   null

End of function tostringperimeter

End of class Rectangle.

Class Triangle:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  __construct
number of ops:  7
compiled vars:  !0 = $l, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   37     2        ASSIGN_OBJ                                               'l'
          3        OP_DATA                                                  !0
   38     4        ASSIGN_OBJ                                               'b'
          5        OP_DATA                                                  !1
   39     6      > RETURN                                                   null

End of function __construct

Function getarea:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  getArea
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   FETCH_OBJ_R                                      ~0      'l'
          1        FETCH_OBJ_R                                      ~1      'b'
          2        MUL                                              ~2      ~0, ~1
          3        MUL                                              ~3      ~2, 0.5
          4      > RETURN                                                   ~3
   43     5*     > RETURN                                                   null

End of function getarea

Function getperimeter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  getPerimeter
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   FETCH_OBJ_R                                      ~0      'l'
          1        FETCH_OBJ_R                                      ~1      'b'
          2        ADD                                              ~2      ~0, ~1
          3        INIT_FCALL                                               'sqrt'
          4        FETCH_OBJ_R                                      ~3      'l'
          5        FETCH_OBJ_R                                      ~4      'l'
          6        MUL                                              ~5      ~3, ~4
          7        FETCH_OBJ_R                                      ~6      'b'
          8        FETCH_OBJ_R                                      ~7      'l'
          9        MUL                                              ~8      ~6, ~7
         10        ADD                                              ~9      ~5, ~8
         11        SEND_VAL                                                 ~9
         12        DO_ICALL                                         $10     
         13        ADD                                              ~11     ~2, $10
         14      > RETURN                                                   ~11
   47    15*     > RETURN                                                   null

End of function getperimeter

Function tostringarea:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  toStringArea
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   GET_CALLED_CLASS                                 ~0      
          1        CONCAT                                           ~1      'The+area+of+the+', ~0
          2        CONCAT                                           ~2      ~1, '+is+'
          3        INIT_METHOD_CALL                                         'getArea'
          4        DO_FCALL                                      0  $3      
          5        CONCAT                                           ~4      ~2, $3
          6        CONCAT                                           ~5      ~4, '%0A'
          7      > RETURN                                                   ~5
    7     8*     > RETURN                                                   null

End of function tostringarea

Function tostringperimeter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  toStringPerimeter
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   GET_CALLED_CLASS                                 ~0      
          1        CONCAT                                           ~1      'The+perimeter+of+the+', ~0
          2        CONCAT                                           ~2      ~1, '+is+'
          3        INIT_METHOD_CALL                                         'getPerimeter'
          4        DO_FCALL                                      0  $3      
          5        CONCAT                                           ~4      ~2, $3
          6        CONCAT                                           ~5      ~4, '%0A'
          7      > RETURN                                                   ~5
   11     8*     > RETURN                                                   null

End of function tostringperimeter

End of class Triangle.

Class Circle:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  __construct
number of ops:  4
compiled vars:  !0 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   RECV                                             !0      
   54     1        ASSIGN_OBJ                                               'r'
          2        OP_DATA                                                  !0
   55     3      > RETURN                                                   null

End of function __construct

Function getarea:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  getArea
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   58     0  E >   FETCH_OBJ_R                                      ~0      'r'
          1        FETCH_OBJ_R                                      ~1      'r'
          2        MUL                                              ~2      ~0, ~1
          3        MUL                                              ~3      ~2, 3.14
          4      > RETURN                                                   ~3
   59     5*     > RETURN                                                   null

End of function getarea

Function getperimeter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  getPerimeter
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   62     0  E >   FETCH_OBJ_R                                      ~0      'r'
          1        MUL                                              ~1      ~0, 2
          2        MUL                                              ~2      ~1, 3.14
          3      > RETURN                                                   ~2
   63     4*     > RETURN                                                   null

End of function getperimeter

Function tostringarea:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  toStringArea
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   GET_CALLED_CLASS                                 ~0      
          1        CONCAT                                           ~1      'The+area+of+the+', ~0
          2        CONCAT                                           ~2      ~1, '+is+'
          3        INIT_METHOD_CALL                                         'getArea'
          4        DO_FCALL                                      0  $3      
          5        CONCAT                                           ~4      ~2, $3
          6        CONCAT                                           ~5      ~4, '%0A'
          7      > RETURN                                                   ~5
    7     8*     > RETURN                                                   null

End of function tostringarea

Function tostringperimeter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IDYbW
function name:  toStringPerimeter
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   GET_CALLED_CLASS                                 ~0      
          1        CONCAT                                           ~1      'The+perimeter+of+the+', ~0
          2        CONCAT                                           ~2      ~1, '+is+'
          3        INIT_METHOD_CALL                                         'getPerimeter'
          4        DO_FCALL                                      0  $3      
          5        CONCAT                                           ~4      ~2, $3
          6        CONCAT                                           ~5      ~4, '%0A'
          7      > RETURN                                                   ~5
   11     8*     > RETURN                                                   null

End of function tostringperimeter

End of class Circle.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.21 ms | 1420 KiB | 15 Q