3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Response { const HTTP_CONTINUE = 100; const HTTP_SWITCHING_PROTOCOLS = 101; const HTTP_OK = 200; const HTTP_CREATED = 201; const HTTP_ACCEPTED = 202; const HTTP_NONAUTHORITATIVE_INFORMATION = 203; const HTTP_NO_CONTENT = 204; const HTTP_RESET_CONTENT = 205; const HTTP_PARTIAL_CONTENT = 206; const HTTP_MULTIPLE_CHOICES = 300; const HTTP_MOVED_PERMANENTLY = 301; const HTTP_FOUND = 302; const HTTP_SEE_OTHER = 303; const HTTP_NOT_MODIFIED = 304; const HTTP_USE_PROXY = 305; const HTTP_UNUSED= 306; const HTTP_TEMPORARY_REDIRECT = 307; const HTTP_BAD_REQUEST = 400; const HTTP_UNAUTHORIZED = 401; const HTTP_PAYMENT_REQUIRED = 402; const HTTP_FORBIDDEN = 403; const HTTP_NOT_FOUND = 404; const HTTP_METHOD_NOT_ALLOWED = 405; const HTTP_NOT_ACCEPTABLE = 406; const HTTP_PROXY_AUTHENTICATION_REQUIRED = 407; const HTTP_REQUEST_TIMEOUT = 408; const HTTP_CONFLICT = 409; const HTTP_GONE = 410; const HTTP_LENGTH_REQUIRED = 411; const HTTP_PRECONDITION_FAILED = 412; const HTTP_REQUEST_ENTITY_TOO_LARGE = 413; const HTTP_REQUEST_URI_TOO_LONG = 414; const HTTP_UNSUPPORTED_MEDIA_TYPE = 415; const HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416; const HTTP_EXPECTATION_FAILED = 417; const HTTP_INTERNAL_SERVER_ERROR = 500; const HTTP_NOT_IMPLEMENTED = 501; const HTTP_BAD_GATEWAY = 502; const HTTP_SERVICE_UNAVAILABLE = 503; const HTTP_GATEWAY_TIMEOUT = 504; const HTTP_VERSION_NOT_SUPPORTED = 505; const HEADER_PREFIX = 'HTTP/1.1 '; private static $_msg = array( 100 => '100 Continue', 101 => '101 Switching Protocols', 200 => '200 OK', 201 => '201 Created', 202 => '202 Accepted', 203 => '203 Non-Authoritative Information', 204 => '204 No Content', 205 => '205 Reset Content', 206 => '206 Partial Content', 300 => '300 Multiple Choices', 301 => '301 Moved Permanently', 302 => '302 Found', 303 => '303 See Other', 304 => '304 Not Modified', 305 => '305 Use Proxy', 306 => '306 (Unused)', 307 => '307 Temporary Redirect', 400 => '400 Bad Request', 401 => '401 Unauthorized', 402 => '402 Payment Required', 403 => '403 Forbidden', 404 => '404 Not Found', 405 => '405 Method Not Allowed', 406 => '406 Not Acceptable', 407 => '407 Proxy Authentication Required', 408 => '408 Request Timeout', 409 => '409 Conflict', 410 => '410 Gone', 411 => '411 Length Required', 412 => '412 Precondition Failed', 413 => '413 Request Entity Too Large', 414 => '414 Request-URI Too Long', 415 => '415 Unsupported Media Type', 416 => '416 Requested Range Not Satisfiable', 417 => '417 Expectation Failed', 500 => '500 Internal Server Error', 501 => '501 Not Implemented', 502 => '502 Bad Gateway', 503 => '503 Service Unavailable', 504 => '504 Gateway Timeout', 505 => '505 HTTP Version Not Supported' ); protected $headers; protected $content; public function appendHeader($header, $autorender = FALSE) { $this->headers[] = $header; $autorender == FALSE || self::renderHeaders(); } public function renderHeaders() { foreach ($this->headers as $header) { header($header); } } public function resetHeaders() { $this->headers = array(); } public function resetContent() { $this->content = ''; } public function addContent($content, $prepend = FALSE) { $content.$this->content = $prepend === TRUE ? $content.$this->content : $this->content.$content; } public function getContent() { return $this->content; } public function render() { $this->renderHeaders(); echo $this->content; } public static function getHeader($code) { return self::HEADER_PREFIX . self::$_msg[$code]; } public static function getMessage($code) { return self::$_msg[$code]; } public static function valid($code) { return is_numeric($code) && $code >= self::HTTP_BAD_REQUEST; } public static function canHaveBody($code) { return ($code < self::HTTP_CONTINUE || $code >= self::HTTP_OK) && $code != self::HTTP_NO_CONTENT && $code != self::HTTP_NOT_MODIFIED; } function __construct() { $this->headers = array(); $this->content = ''; } } var_dump(new Response);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iGLu6
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  148     0  E >   INIT_FCALL                                               'var_dump'
          1        NEW                                              $0      'Response'
          2        DO_FCALL                                      0          
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                                 
          5      > RETURN                                                   1

Class Response:
Function appendheader:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/iGLu6
function name:  appendHeader
number of ops:  11
compiled vars:  !0 = $header, !1 = $autorender
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   94     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <false>
   95     2        FETCH_OBJ_W                                      $2      'headers'
          3        ASSIGN_DIM                                               $2
          4        OP_DATA                                                  !0
   96     5        BOOL_NOT                                         ~4      !1
          6      > JMPNZ_EX                                         ~4      ~4, ->10
          7    >   INIT_STATIC_METHOD_CALL                                  'renderHeaders'
          8        DO_FCALL                                      0  $5      
          9        BOOL                                             ~4      $5
   97    10    > > RETURN                                                   null

End of function appendheader

Function renderheaders:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 7
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/iGLu6
function name:  renderHeaders
number of ops:  9
compiled vars:  !0 = $header
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  100     0  E >   FETCH_OBJ_R                                      ~1      'headers'
          1      > FE_RESET_R                                       $2      ~1, ->7
          2    > > FE_FETCH_R                                               $2, !0, ->7
  101     3    >   INIT_FCALL                                               'header'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                                 
  100     6      > JMP                                                      ->2
          7    >   FE_FREE                                                  $2
  103     8      > RETURN                                                   null

End of function renderheaders

Function resetheaders:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iGLu6
function name:  resetHeaders
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  105     0  E >   ASSIGN_OBJ                                               'headers'
          1        OP_DATA                                                  <array>
  106     2      > RETURN                                                   null

End of function resetheaders

Function resetcontent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iGLu6
function name:  resetContent
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  108     0  E >   ASSIGN_OBJ                                               'content'
          1        OP_DATA                                                  ''
  109     2      > RETURN                                                   null

End of function resetcontent

Function addcontent:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iGLu6
function name:  addContent
number of ops:  16
compiled vars:  !0 = $content, !1 = $prepend
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  110     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <false>
  111     2        TYPE_CHECK                                    8          !1
          3      > JMPZ                                                     ~3, ->8
          4    >   FETCH_OBJ_R                                      ~4      'content'
          5        CONCAT                                           ~5      !0, ~4
          6        QM_ASSIGN                                        ~6      ~5
          7      > JMP                                                      ->11
          8    >   FETCH_OBJ_R                                      ~7      'content'
          9        CONCAT                                           ~8      ~7, !0
         10        QM_ASSIGN                                        ~6      ~8
         11    >   ASSIGN_OBJ                                       ~2      'content'
         12        OP_DATA                                                  ~6
         13        CONCAT                                           ~9      !0, ~2
         14        FREE                                                     ~9
  112    15      > RETURN                                                   null

End of function addcontent

Function getcontent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iGLu6
function name:  getContent
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  114     0  E >   FETCH_OBJ_R                                      ~0      'content'
          1      > RETURN                                                   ~0
  115     2*     > RETURN                                                   null

End of function getcontent

Function render:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iGLu6
function name:  render
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  118     0  E >   INIT_METHOD_CALL                                         'renderHeaders'
          1        DO_FCALL                                      0          
  119     2        FETCH_OBJ_R                                      ~1      'content'
          3        ECHO                                                     ~1
  120     4      > RETURN                                                   null

End of function render

Function getheader:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iGLu6
function name:  getHeader
number of ops:  6
compiled vars:  !0 = $code
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  122     0  E >   RECV                                             !0      
  124     1        FETCH_STATIC_PROP_R          unknown             ~1      '_msg'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3        CONCAT                                           ~3      'HTTP%2F1.1+', ~2
          4      > RETURN                                                   ~3
  125     5*     > RETURN                                                   null

End of function getheader

Function getmessage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iGLu6
function name:  getMessage
number of ops:  5
compiled vars:  !0 = $code
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  127     0  E >   RECV                                             !0      
  130     1        FETCH_STATIC_PROP_R          unknown             ~1      '_msg'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
  131     4*     > RETURN                                                   null

End of function getmessage

Function valid:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/iGLu6
function name:  valid
number of ops:  9
compiled vars:  !0 = $code
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  133     0  E >   RECV                                             !0      
  134     1        INIT_FCALL                                               'is_numeric'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > JMPZ_EX                                          ~2      $1, ->7
          5    >   IS_SMALLER_OR_EQUAL                              ~3      400, !0
          6        BOOL                                             ~2      ~3
          7    > > RETURN                                                   ~2
  135     8*     > RETURN                                                   null

End of function valid

Function canhavebody:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
Branch analysis from position: 8
Branch analysis from position: 5
filename:       /in/iGLu6
function name:  canHaveBody
number of ops:  13
compiled vars:  !0 = $code
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  137     0  E >   RECV                                             !0      
  138     1        IS_SMALLER                                       ~1      !0, 100
          2      > JMPNZ_EX                                         ~1      ~1, ->5
          3    >   IS_SMALLER_OR_EQUAL                              ~2      200, !0
          4        BOOL                                             ~1      ~2
          5    > > JMPZ_EX                                          ~1      ~1, ->8
          6    >   IS_NOT_EQUAL                                     ~3      !0, 204
          7        BOOL                                             ~1      ~3
          8    > > JMPZ_EX                                          ~1      ~1, ->11
          9    >   IS_NOT_EQUAL                                     ~4      !0, 304
         10        BOOL                                             ~1      ~4
         11    > > RETURN                                                   ~1
  139    12*     > RETURN                                                   null

End of function canhavebody

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iGLu6
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  142     0  E >   ASSIGN_OBJ                                               'headers'
          1        OP_DATA                                                  <array>
  143     2        ASSIGN_OBJ                                               'content'
          3        OP_DATA                                                  ''
  144     4      > RETURN                                                   null

End of function __construct

End of class Response.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.78 ms | 1408 KiB | 19 Q