summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/pages/Controls/Statements.page
blob: f37f1dc4e869d7ad4d54e06b21fff263a51cb5ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<com:TContent ID="body" >

<h1>TStatements</h1>
<com:DocLink ClassPath="System.Web.UI.WebControls.TStatements" />

<p>
<tt>TStatements</tt> evaluates a sequence of PHP statements and displays the content rendered by the statements. To specify the PHP statements to be evaluated, set the <tt>Statements</tt> property. In a control template, <a href="?page=Configurations.Templates2#st">statement tags</a> are often used instead of the complete <a href="?page=Configurations.Templates1#ct">component tags</a> when the main purpose is to display the result rendered by some PHP statements. For example, the following two tags are equivalent,
</p>
<com:TTextHighlighter Language="prado" CssClass="source">
&lt;com:TStatements&gt;
  &lt;prop:Expression&gt;
  setlocale(LC_ALL, 'nl_NL');
  echo strftime("%A %e %B %Y",time());
  &lt;/prop:Expression&gt;
&lt;/com:TStatements&gt;

&lt;%%
  setlocale(LC_ALL, 'nl_NL');
  echo strftime("%A %e %B %Y",time());
%&gt;
</com:TTextHighlighter>

<p>
<tt>TStatements</tt> evaluates the PHP statements during the rendering control lifecycle. Unlike <tt>TExpression</tt>, <tt>TStatements</tt> only displays the content 'echoed' within the statements.
</p>

<p>
The context of the statements in a <tt>TStatements</tt> control is the control itself. That is, <tt>$this</tt> represents the control object if it is present in the statements. For example, the following statement tag will display the title of the page containing the <tt>TStatements</tt> control.
</p>
<com:TTextHighlighter Language="prado" CssClass="source">
&lt;%%
  $page=$this->Page;
  echo $page->Title;
%&gt;
</com:TTextHighlighter>

<p>
Be aware, since <tt>TStatements</tt> allows execution of arbitrary PHP code, in general you should not use it to evaluate PHP code submitted by your application users.
</p>

</com:TContent>