PHP Classes

File: thisisonlyatest.pat

Recommend this page to a friend!
  Classes of Tomas B   phpEngine   thisisonlyatest.pat   Download  
File: thisisonlyatest.pat
Role: Auxiliary data
Content type: text/plain
Description: Template file
Class: phpEngine
Regular expression match based template engine
Author: By
Last change: Sample auxiliary file now includes a short review about phpEngine. At the same time it tests phpEngine.
Date: 20 years ago
Size: 3,606 bytes
 

Contents

Class file image Download
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="lt" lang="lt" dir="ltr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=charset=iso-8859-1" /> <meta name="robots" content="noindex,nofollow"> <title><var>version</var>: sample pattern</title> <style type="text/css"> body { font-family: Arial; } h1 { margin: 2px; background: #DADFC5; font-family: "Arial Narrow", "Trebuchet MS", Tahoma, Arial; text-align: center; } div#container div { float: left; width: 33%; } code { display: block; padding: 2px; margin-bottom: 5px; background: #EDEFE3; color: #800000; } span, code, p { margin-right: 5px; } span { font-size: small; } </style> </head> <body> <div id="container"> <div> <h1>VAR</h1> <p>Example 1: <strong>User assigned variable</strong></p> <span><em>PHP code:</em></span> <code>phpEngine::assign("<u>var1</u>", "<em>This is a user assigned variable</em>");</code> <span><em>Pattern code:</em></span> <code>&lt;var&gt;<u>var1</u>&lt;/var&gt;</code> <span><em>phpEngine output:</em></span> <code><em><var>var1</var></em></code> <p>Example 2: <strong>Global variable <em>version</em></strong></p> <span><em>Pattern code:</em></span> <code>&lt;var&gt;<u>version</u>&lt;/var&gt;</code> <span><em>phpEngine output:</em></span> <code><em><var>version</var></em></code> </div> <div> <h1>INC</h1> <p>Example 3: <strong>Including file pattern</strong></p> <span><em>Pattern code:</em></span> <code>&lt;inc&gt;<u>example.pat</u>&lt;/inc&gt;</code> <span><em>phpEngine output:</em></span> <code><inc>include.pat</inc></code> <p>Example 4: <strong>Using a shifting file name for inclusion</strong></p> <span><em>PHP code:</em></span> <code>phpEngine::assign("<u>include</u>", "<em>example.pat</em>");</code> <span><em>Pattern code:</em></span> <code>&lt;inc&gt;<u>include</u>&lt;/inc&gt;</code> <span><em>phpEngine output:</em></span> <code><inc>include</inc></code> </div> <div> <h1>LOOP</h1> <p>Example 5: <strong>Looping data</strong></p> <span><em>PHP code:</em></span> <code>$data_array = array( array("Max", "1072908000"), array("Liz", "1076796000"), array("Maria", "1078178400")); phpEngine::assign("<u>loop_name</u>", $data_array, "<em>name, unix_time</em>");</code> <p>Example 5.1: <strong>Printing the value</strong></p> <span><em>Pattern code:</em></span> <code>&lt;loop name="<u>loop_name</u>"&gt;{<em>name</em>} &lt;/loop&gt;</code> <span><em>phpEngine output:</em></span> <code><em><loop name="loop_name">{name} </loop></em></code> <p>Example 5.2: <strong>Printing the placeholder title (key)</strong></p> <span><em>Pattern code:</em></span> <code>&lt;loop name="<u>loop_name</u>"&gt;{<em>name::this</em>} &lt;/loop&gt;</code> <span><em>phpEngine output:</em></span> <code><em><loop name="loop_name">{name::this} </loop></em></code> <p>Example 5.3: <strong>Adding global placeholder <em>lnum</em> (line/loop number)</strong></p> <span><em>Pattern code:</em></span> <code>&lt;loop name="<u>loop_name</u>"&gt;{<em>lnum</em>}.{<em>name</em>} &lt;/loop&gt;</code> <span><em>phpEngine output:</em></span> <code><em><loop name="loop_name">{lnum}.{name} </loop></em></code> <p>Example 5.4: <strong>Detecting unix timestamp</strong></p> <span><em>Pattern code:</em></span> <code>&lt;loop name="<u>loop_name</u>"&gt;{<em>unix_time</em>}; &lt;/loop&gt;</code> <span><em>phpEngine output:</em></span> <code><em><loop name="loop_name">{unix_time}; </loop></em></code> </div> </div> </body> </html>