Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 3ca7e0e5486da714e98ac79af09ca745 > files > 99

php-smarty2-doc-2.6.28-2.mga4.noarch.rpm

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>default</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.1">
<link rel="home" href="index.html" title="Smarty Manual">
<link rel="up" href="language.modifiers.html" title="Chapter 5. Variable Modifiers">
<link rel="prev" href="language.modifier.date.format.html" title="date_format">
<link rel="next" href="language.modifier.escape.html" title="escape">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">default</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="language.modifier.date.format.html">Prev</a> </td>
<th width="60%" align="center">Chapter 5. Variable Modifiers</th>
<td width="20%" align="right"> <a accesskey="n" href="language.modifier.escape.html">Next</a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect1" title="default">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="language.modifier.default"></a>default</h2></div></div></div>
<p>
     This is used to set a default value for a variable. If the variable
     is unset or an empty string, the given default value is printed instead.
     Default takes the one argument.
  </p>
<p>
     </p>
<div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>
       With <a class="ulink" href="http://php.net/error_reporting" target="_top">
       <code class="varname">error_reporting(E_ALL)</code></a>,
       undeclared variables will always throw an error within the template.
       This function is useful for replacing null or zero length strings.
    </p>
</div>
<p>
    </p>
<div class="informaltable"><table border="1">
<colgroup>
<col align="center">
<col align="center">
<col align="center">
<col align="center">
<col>
</colgroup>
<thead><tr>
<th align="center">Parameter Position</th>
<th align="center">Type</th>
<th align="center">Required</th>
<th align="center">Default</th>
<th>Description</th>
</tr></thead>
<tbody><tr>
<td align="center">1</td>
<td align="center">string</td>
<td align="center">No</td>
<td align="center"><span class="emphasis"><em>empty</em></span></td>
<td>This is the default value to output if the
       variable is empty.</td>
</tr></tbody>
</table></div>
<div class="example">
<a name="id3036177"></a><p class="title"><b>Example 5.9. default</b></p>
<div class="example-contents">
<pre class="programlisting">

&lt;?php

$smarty-&gt;assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
$smarty-&gt;assign('email', '');

?&gt;

   </pre>
<p>
    Where template is:
   </p>
<pre class="programlisting">

{$articleTitle|default:'no title'}
{$myTitle|default:'no title'}
{$email|default:'No email address available'}

   </pre>
<p>
    Will output:
   </p>
<pre class="screen">

Dealers Will Hear Car Talk at Noon.
no title
No email address available

   </pre>
</div>
</div>
<br class="example-break"><p>
   See also the
   <a class="link" href="tips.default.var.handling.html" title="Default Variable Handling">default variable handling</a>
   and the
   <a class="link" href="tips.html#tips.blank.var.handling" title="Blank Variable Handling">blank variable handling</a> pages.
  </p>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="language.modifier.date.format.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="language.modifiers.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="language.modifier.escape.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">date_format </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> escape</td>
</tr>
</table>
</div>
</body>
</html>