if statement
Moderator: General Moderators
if statement
Yes I know there's a syntax error and I know it's a basic thing but could someone help me?
$ww = "aa";
$ww == "aa"? echo "bb";echo "cc";
$ww = "aa";
$ww == "aa"? echo "bb";echo "cc";
- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada
I think you want this:
Code: Select all
$ww="aa";
if ($ww=="aa")
{
echo "aa";
}
else if ($ww=="bb")
{
echo "bb";
}
else
{
echo "Not aa or bb";
}- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada
hmm, I'm not too familiar with C++, and I definitly don't remeber that in C (unless I've forgotten it entirely). I've never come accross anything like this in PHP, try querying the PHP manual (http://www.php.net), see if you can get anything.
Good luck.
Good luck.
- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada
Code: Select all
<?
$ww = "aa";
echo ($ww == "aa") ? "bb":"cc";
?>Basically...
Code: Select all
echo ($ww == "aa") ? "bb":"cc";
// Is the same as
if ( $ww == "aa") { echo "bb"; } else { echo "cc"; }- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
It is also possible to shorten:
to
Mac
Code: Select all
($ww == "aa")?$pp = true:$pp = false;Code: Select all
$pp = ($ww == 'aa') ? true : false;