Basic Syntax

PHPoC tags

PHPoC script consists of two tags: opening tag (<?php or <?) and closing tag (?>). Meaning of these tags is start and end of script. Everything outside of a pair of these tags is ignored by PHPoC parser and printed to standard output port. In case of webpage, the ignored text is sent to web browser.

<?php                   // opening tag
  echo "Hello PHPoC!";  // script
?>                      // closing tag

Inserting PHPoC Script into Webpage (HTML)

Features of everything outside of a pair of opening and closing tags are ignored by the PHPoC parser which allows PHPoC to be embedded in HTML documents.

<p>This will be ignored by PHPoC and displayed by the browser. </p>
<?php echo "While this will be parsed."; ?>
<p>This will also be ignored by PHPoC and displayed by the browser. </p>

By using conditional statement, PHPoC can determine the outcome of text which is outside of PHPoC tags. See the example below.

<?php if(true){ ?>
This will show if the expression is true. <!-- This will be displayed -->
<?php } else { ?>
Otherwise this will show.                 <!-- This will not be displayed -->
<?php } ?>

Instruction Separation

As in C, PHPoC requires instructions to be terminated with a semicolon at the end of each statement. The closing tag of a block of PHPoC statements automatically implies a semicolon; you do not need to type a semicolon.

  echo "the first statement.\r\n";          // the first line, ';' is used
  echo "the last statement.\r\n"            // the last line, ';' can be omitted
<?php echo "single line statement.\r\n" ?>  // single line, ';' can be omitted

※ Although you can omit a semicolon, we recommend using semicolon at all times because it is not correct syntax.


As 'C' and 'C++', PHPoC supports one-line and multiple-line comments.

  echo "the first statement.\r\n";          // one-line comment
  /* This
  multiple-line comment. */
  echo "the last statement.\r\n";

※ UNIX shell-style comment '#' is not supported in PHPoC.