3v4l.org

run code in 300+ PHP versions simultaneously
<?php require("php_serial.class.php"); if (isset($_GET['action'])) { $serial = new phpSerial; $serial->deviceSet("/dev/ttyACM0"); $serial->confBaudRate(115200); $serial->deviceOpen(); if ($_GET['action'] == "greenon") { $serial->sendMessage("0"); $done = false; $line = ""; while (!$done) { $read = $serial->readPort(); for ($i = 0; $i < strlen($read); $i++) { if ($read[$i] == "\n") { $done = true; echo "Response from Arduino: ".$line."\n"; $line = ""; } else { $line .= $read[$i]; } } } } else if ($_GET['action'] == "greenoff") { $serial->sendMessage("1\r"); } else if ($_GET['action'] == "redon") { $serial->sendMessage("2\r"); $read = $serial->readPort(); echo $read; } else if ($_GET['action'] == "redoff") { $serial->sendMessage("3\r"); } $serial->deviceClose(); } ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Arduino Project 1: Serial LED Control</title> </head> <body> <h1>Arduino Project 1: Serial LED Control</h1> <p><a href="<?=$_SERVER['PHP_SELF'] . "?action=greenon" ?>"> Click here to turn pin13 on.</a></p> <p><a href="<?=$_SERVER['PHP_SELF'] . "?action=greenoff" ?>"> Click here to turn pin13 off.</a></p> <p><a href="<?=$_SERVER['PHP_SELF'] . "?action=redon" ?>"> Click here to turn the RED LED on.</a></p> <p><a href="<?=$_SERVER['PHP_SELF'] . "?action=redoff" ?>"> Click here to turn the RED LED off.</a></p> </body> </html>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 77
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 48
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 25
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 75
Branch analysis from position: 75
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 30
Branch analysis from position: 45
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 39
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 30
Branch analysis from position: 45
Branch analysis from position: 30
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 30
Branch analysis from position: 45
Branch analysis from position: 30
Branch analysis from position: 48
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 56
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 75
Branch analysis from position: 75
Branch analysis from position: 56
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 68
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 75
Branch analysis from position: 75
Branch analysis from position: 68
2 jumps found. (Code = 43) Position 1 = 72, Position 2 = 75
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 75
Branch analysis from position: 77
filename:       /in/qZ1FE
function name:  (null)
number of ops:  99
compiled vars:  !0 = $serial, !1 = $done, !2 = $line, !3 = $read, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INCLUDE_OR_EVAL                                          'php_serial.class.php', REQUIRE
    5     1        FETCH_IS                                         ~6      '_GET'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~6, 'action'
          3      > JMPZ                                                     ~7, ->77
    9     4    >   NEW                                              $8      'phpSerial'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $8
   11     7        INIT_METHOD_CALL                                         !0, 'deviceSet'
          8        SEND_VAL_EX                                              '%2Fdev%2FttyACM0'
          9        DO_FCALL                                      0          
   13    10        INIT_METHOD_CALL                                         !0, 'confBaudRate'
         11        SEND_VAL_EX                                              115200
         12        DO_FCALL                                      0          
   15    13        INIT_METHOD_CALL                                         !0, 'deviceOpen'
         14        DO_FCALL                                      0          
   17    15        FETCH_R                      global              ~14     '_GET'
         16        FETCH_DIM_R                                      ~15     ~14, 'action'
         17        IS_EQUAL                                                 ~15, 'greenon'
         18      > JMPZ                                                     ~16, ->48
   21    19    >   INIT_METHOD_CALL                                         !0, 'sendMessage'
         20        SEND_VAL_EX                                              '0'
         21        DO_FCALL                                      0          
   23    22        ASSIGN                                                   !1, <false>
   25    23        ASSIGN                                                   !2, ''
   27    24      > JMP                                                      ->45
   31    25    >   INIT_METHOD_CALL                                         !0, 'readPort'
         26        DO_FCALL                                      0  $20     
         27        ASSIGN                                                   !3, $20
   33    28        ASSIGN                                                   !4, 0
         29      > JMP                                                      ->42
   37    30    >   FETCH_DIM_R                                      ~23     !3, !4
         31        IS_EQUAL                                                 ~23, '%0A'
         32      > JMPZ                                                     ~24, ->39
   41    33    >   ASSIGN                                                   !1, <true>
   43    34        CONCAT                                           ~26     'Response+from+Arduino%3A+', !2
         35        CONCAT                                           ~27     ~26, '%0A'
         36        ECHO                                                     ~27
   45    37        ASSIGN                                                   !2, ''
         38      > JMP                                                      ->41
   53    39    >   FETCH_DIM_R                                      ~29     !3, !4
         40        ASSIGN_OP                                     8          !2, ~29
   33    41    >   PRE_INC                                                  !4
         42    >   STRLEN                                           ~32     !3
         43        IS_SMALLER                                               !4, ~32
         44      > JMPNZ                                                    ~33, ->30
   27    45    >   BOOL_NOT                                         ~34     !1
         46      > JMPNZ                                                    ~34, ->25
         47    > > JMP                                                      ->75
   63    48    >   FETCH_R                      global              ~35     '_GET'
         49        FETCH_DIM_R                                      ~36     ~35, 'action'
         50        IS_EQUAL                                                 ~36, 'greenoff'
         51      > JMPZ                                                     ~37, ->56
   67    52    >   INIT_METHOD_CALL                                         !0, 'sendMessage'
         53        SEND_VAL_EX                                              '1%0D'
         54        DO_FCALL                                      0          
         55      > JMP                                                      ->75
   71    56    >   FETCH_R                      global              ~39     '_GET'
         57        FETCH_DIM_R                                      ~40     ~39, 'action'
         58        IS_EQUAL                                                 ~40, 'redon'
         59      > JMPZ                                                     ~41, ->68
   75    60    >   INIT_METHOD_CALL                                         !0, 'sendMessage'
         61        SEND_VAL_EX                                              '2%0D'
         62        DO_FCALL                                      0          
   77    63        INIT_METHOD_CALL                                         !0, 'readPort'
         64        DO_FCALL                                      0  $43     
         65        ASSIGN                                                   !3, $43
   79    66        ECHO                                                     !3
         67      > JMP                                                      ->75
   83    68    >   FETCH_R                      global              ~45     '_GET'
         69        FETCH_DIM_R                                      ~46     ~45, 'action'
         70        IS_EQUAL                                                 ~46, 'redoff'
         71      > JMPZ                                                     ~47, ->75
   87    72    >   INIT_METHOD_CALL                                         !0, 'sendMessage'
         73        SEND_VAL_EX                                              '3%0D'
         74        DO_FCALL                                      0          
   91    75    >   INIT_METHOD_CALL                                         !0, 'deviceClose'
         76        DO_FCALL                                      0          
   99    77    >   ECHO                                                     '%3C%21DOCTYPE+HTML+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+HTML+4.01+Transitional%2F%2FEN%22+%0A%0A%22http%3A%2F%2Fwww.w3.org%2FTR%2Fhtml4%2Floose.dtd%22%3E+%0A%0A%3Chtml%3E+%0A%0A%3Chead%3E+%0A%0A%3Cmeta+http-equiv%3D%22Content-Type%22+content%3D%22text%2Fhtml%3B+charset%3Diso-8859-1%22%3E+%0A%0A%3Ctitle%3EArduino+Project+1%3A+Serial+LED+Control%3C%2Ftitle%3E+%0A%0A%3C%2Fhead%3E+%0A%0A%3Cbody%3E+%0A%0A+%0A%0A%3Ch1%3EArduino+Project+1%3A+Serial+LED+Control%3C%2Fh1%3E+%0A%0A%3Cp%3E%3Ca+href%3D%22'
  119    78        FETCH_R                      global              ~50     '_SERVER'
         79        FETCH_DIM_R                                      ~51     ~50, 'PHP_SELF'
         80        CONCAT                                           ~52     ~51, '%3Faction%3Dgreenon'
         81        ECHO                                                     ~52
         82        ECHO                                                     '%22%3E%0A%0AClick+here+to+turn+pin13+on.%3C%2Fa%3E%3C%2Fp%3E+%0A%0A%3Cp%3E%3Ca+href%3D%22'
  123    83        FETCH_R                      global              ~53     '_SERVER'
         84        FETCH_DIM_R                                      ~54     ~53, 'PHP_SELF'
         85        CONCAT                                           ~55     ~54, '%3Faction%3Dgreenoff'
         86        ECHO                                                     ~55
         87        ECHO                                                     '%22%3E%0A%0AClick+here+to+turn+pin13+off.%3C%2Fa%3E%3C%2Fp%3E+%0A%0A%3Cp%3E%3Ca+href%3D%22'
  127    88        FETCH_R                      global              ~56     '_SERVER'
         89        FETCH_DIM_R                                      ~57     ~56, 'PHP_SELF'
         90        CONCAT                                           ~58     ~57, '%3Faction%3Dredon'
         91        ECHO                                                     ~58
         92        ECHO                                                     '%22%3E%0A%0AClick+here+to+turn+the+RED+LED+on.%3C%2Fa%3E%3C%2Fp%3E+%0A%0A%3Cp%3E%3Ca+href%3D%22'
  131    93        FETCH_R                      global              ~59     '_SERVER'
         94        FETCH_DIM_R                                      ~60     ~59, 'PHP_SELF'
         95        CONCAT                                           ~61     ~60, '%3Faction%3Dredoff'
         96        ECHO                                                     ~61
         97        ECHO                                                     '%22%3E%0A%0AClick+here+to+turn+the+RED+LED+off.%3C%2Fa%3E%3C%2Fp%3E+%0A%0A%3C%2Fbody%3E+%0A%0A%3C%2Fhtml%3E'
  137    98      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.03 ms | 1403 KiB | 13 Q