Basic uPHP Syntax

uPHP Tags

When Wattmon parses a file, it looks for opening and closing tags, which are <? and ?> which tell Wattmon to start and stop interpreting the code between them. Parsing in this manner allows you to integrate script code within an HTML file as everything outside of a pair of opening and closing tags is ignored by the uPHP parser.


 Some text
print(‘hello, uPHP’);
Some more text

In addition, you can integrate multiple code blocks with a page, even if it is within a uPHP code block.  For example if you wished to display a block of HTML based on a uPHP condition, it would go something like this:



If ($myconditing > 5) {
?> This will only be output if my condition > 5
<? } else { ?>
This will be output if the first condition is not true.
<? } ?>


Instruction Separation

As in C and PHP, uPHP requires instructions to be terminated with a semicolon at the end of each statement. The closing tag of a block of uPHP code automatically implies a semicolon; you do not need to have a semicolon terminating the last line of a uPHP block. The closing tag for the block will include the immediately trailing newline if one is present.



uPHP supports 'C', 'C++' and Unix shell-style (Perl style) comments. For example:

// comment 1
/* comment 3 */

The "one-line" comment styles only comment to the end of the line or the current block of uPHP code, whichever comes first. This means that HTML code after // ... ?> or # ... ?> WILL be printed: ?> breaks out of uPHP mode and returns to HTML mode, and // or # cannot influence that. 

Note:  Firmware versions below 1.1008 require a line break after a single line comment in order to close the script block or else a parse error will be raised.


'C' style comments end at the first */ encountered. Make sure you don't nest 'C' style comments. It is easy to make this mistake if you are trying to comment out a large block of code.


    echo 'This is a test'; /* This comment will cause a problem */
 */ ?>