List Info

Thread: note 79015 added to control-structures.alternative-syntax




note 79015 added to control-structures.alternative-syntax
user name
2007-11-06 23:44:10
<?php
/*
TENARY OPERATOR : ALTERNATIVE SYNTAX

Expr-1 (True or False) ? Expr-2 (True) : Expr-3 (False);
Condition to be evaluated or Boolean Expression to be
evaluated True or False ?
Codes to be excuted , if true :
codes to be executed, if false;

The following codes can be replaced by following tenary
expression as shown:
*/

$a=24;

/*  // Codes replacement by tenary expression.
if($a == 1)
{
    $var = "One";
}
else if($a == 24)
{
    $var = "Twenty Four";
}
else
{
    $var = "Not One nor Twenty Four";
}
*/

$var=$a==1? "One" :($a==24? "Twenty
Four":"Not One nor Twenty Four");
echo "$varn<br>";

/*
Which generates following output as $a = 24
Twenty Four
*/

?>
----
Server IP: 69.147.83.197
Probable Submitter: 208.79.60.30
----
Manual Page -- http://www.php.net/manual/en/control-struc
tures.alternative-syntax.php
Edit        -- https://master
.php.net/note/edit/79015
Del: integrated  -- h
ttps://master.php.net/note/delete/79015/integrated
Del: useless     -- http
s://master.php.net/note/delete/79015/useless
Del: bad code    -- htt
ps://master.php.net/note/delete/79015/bad+code
Del: spam        -- https:/
/master.php.net/note/delete/79015/spam
Del: non-english -- 
https://master.php.net/note/delete/79015/non-english
Del: in docs     -- http
s://master.php.net/note/delete/79015/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/79015
Reject      -- https://mast
er.php.net/note/reject/79015
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


note 79015 deleted from control-structures.alternative-syntax by tularis
user name
2007-11-07 02:55:20
Note Submitter: SID TRIVEDI
Reason: useless

----

<?php
/*
TENARY OPERATOR : ALTERNATIVE SYNTAX

Expr-1 (True or False) ? Expr-2 (True) : Expr-3 (False);
Condition to be evaluated or Boolean Expression to be
evaluated True or False ?
Codes to be excuted , if true :
codes to be executed, if false;

The following codes can be replaced by following tenary
expression as shown:
*/

$a=24;

/*  // Codes replacement by tenary expression.
if($a == 1)
{
    $var = "One";
}
else if($a == 24)
{
    $var = "Twenty Four";
}
else
{
    $var = "Not One nor Twenty Four";
}
*/

$var=$a==1? "One" :($a==24? "Twenty
Four":"Not One nor Twenty Four");
echo "$varn<br>";

/*
Which generates following output as $a = 24
Twenty Four
*/

?>

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )