User Tools

Site Tools


uphp:uphp_language_basics

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
uphp:uphp_language_basics [2017/02/12 11:03]
jeff
uphp:uphp_language_basics [2021/09/13 05:57] (current)
Line 1: Line 1:
-====== uPHP Language Basics ======+======uPHP Language Basics======
  
 The following sections describe how to work with uPHP scripts. The following sections describe how to work with uPHP scripts.
  
-===== uPHP Tags =====+=====uPHP Tags=====
  
- +When [[hardware:wattmons|Wattmon]] parses a file, it looks for opening and closing tags, which are ''<?'' and ''?>'' respectively. This tells [[hardware:wattmons|Wattmon]] to start and stop interpreting the uPHP 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.
-When Wattmon parses a file, it looks for opening and closing tags, which are ''<?'' and ''?>'' respecively. This tells 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.+
  
 <code php> <code php>
 Some text Some text
 <? <?
-print(‘hello, uPHP’);+  print(‘hello, uPHP’);
 ?> ?>
 Some more text Some more text
 </code> </code>
  
-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:+In addition, you can integrate multiple code blocks within 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:
  
-<code php><? +<code php> 
- +<? 
-If ($mycondition > 5) { +  If ($mycondition > 5) { 
-?> This will only be output if my condition > 5 +    ?> This will only be output if my condition > 5 <? 
-<? } else { ?> +  } else { 
-This will be output if the first condition is not true. +    ?> This will be output if the first condition is not true. <? 
-<? } ?>+  } 
 +?>
 </code> </code>
    
-===== Instruction Separation =====+=====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. 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.
  
    
-===== Comments =====+=====Comments=====
  
 uPHP supports 'C', 'C++' and Unix shell-style (Perl style) comments. For example: uPHP supports 'C', 'C++' and Unix shell-style (Perl style) comments. For example:
  
-<code php><?  +<code php> 
-// comment 1 +<? 
-$x=1; +  // comment 1 
-#comment2 +  $x=1; 
-$x=2; +  # comment2 
-print($x); +  $x=2; 
-/* comment 3 */ +  print($x); 
-$x=3; +  /* comment 3 */ 
-print($x);+  $x=3; 
 +  print($x);
 ?> ?>
 </code> </code>
  
-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. +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.
  
 '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. '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.
    
-<code php><?+<code php> 
 +<?
 /* /*
-    echo 'This is a test'; /* This comment will cause a problem */ +echo 'This is a test'; /* This comment will cause a problem */ 
- */ ?>+echo 'Print this also'; 
 +*/ 
 +?>
 </code> </code>
  
-===== Programmer Reference =====+=====Programmer Reference===== 
 + 
 +  * [[functions|uPHP Function Reference]] - The entire function list (advanced)
  
-  * [[.functions:uphp_function_reference|uPHP Reference]] +  * [[uPHP Special Variables]] - Special arrays that are populated automatically before a script is run
-  * [[.uphp_special_variables|uPHP Special Variables]]+
  
  
uphp/uphp_language_basics.1486897417.txt.gz · Last modified: 2021/09/13 05:56 (external edit)