git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@219226 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Sean Coates 2006-09-01 15:37:21 +00:00
parent 3a9d373d06
commit 17a283bd6a

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.103 $ -->
<!-- $Revision: 1.104 $ -->
<chapter id="language.operators">
<title>Operators</title>
<simpara>
@ -654,20 +654,20 @@ function standard_array_compare($op1, $op2)
<example>
<title>Assigning a default value</title>
<programlisting role="php">
<![CDATA[
<?php
// Example usage for: Ternary Operator
$action = (empty($_POST['action'])) ? 'default' : $_POST['action'];
<![CDATA[
<?php
// Example usage for: Ternary Operator
$action = (empty($_POST['action'])) ? 'default' : $_POST['action'];
// The above is identical to this if/else statement
if (empty($_POST['action'])) {
$action = 'default';
} else {
$action = $_POST['action'];
}
// The above is identical to this if/else statement
if (empty($_POST['action'])) {
$action = 'default';
} else {
$action = $_POST['action'];
}
?>
]]>
?>
]]>
</programlisting>
</example>
The expression <literal>(expr1) ? (expr2) : (expr3)</literal>