Author |
Message |
Kdawg
Senior WebHelper
Joined: 21 Apr 2003
Posts: 153
|
Posted:
Sat Apr 26, 2003 12:52 am (20 years, 12 months ago) |
|
How is a PHP if statment formated, like if $game = North Royaltin then $game = North_Royaltin? |
|
|
|
|
Daniel
Team Member
Joined: 06 Jan 2002
Posts: 2564
|
Posted:
Sat Apr 26, 2003 7:29 am (20 years, 12 months ago) |
|
A correct if statement would be:
Code: | if ($game = 'North Royaltin') {
function_to_run();
} |
Although the code you gave doesn't make sense, since it doesn't do anything |
________________________________
|
|
|
|
adam
Forum Moderator & Developer
Joined: 26 Jul 2002
Posts: 704
Location: UK
|
Posted:
Sat Apr 26, 2003 9:32 am (20 years, 12 months ago) |
|
that should be:
Code: | if ($game == 'North Royaltin') {
function_to_run();
} |
note the double equals |
________________________________ It's turtles all the way down... |
|
|
|
Daniel
Team Member
Joined: 06 Jan 2002
Posts: 2564
|
Posted:
Sat Apr 26, 2003 12:11 pm (20 years, 12 months ago) |
|
Sorry - teach me to check out these forums when I have only 5 minutes on the PC |
________________________________
|
|
|
|
drathbun
WebHelper
Joined: 01 Mar 2003
Posts: 69
Location: Texas
|
Posted:
Sat Apr 26, 2003 10:17 pm (20 years, 12 months ago) |
|
You'll also often see this, if there is just a single statement to be evaluated:
Code: | $some_var = ($testvar == 'some value') ? $true_result : $false_result; |
This is identical (at least from a functional standpoint) to:
Code: | if ($testvar == 'some value')
{
$some_var = $true_result
}
else
{
$some_var = $false_result
} |
It just does it all on one line. I use this quite frequently, actually.
Dave |
________________________________ Dave
Photography Site :: Query Tools Forum :: Weekend Fun |
|
|
|
Iyonix
WebHelper
Joined: 12 Nov 2002
Posts: 82
Location: Yarm, England
|
Posted:
Sun Apr 27, 2003 9:04 am (20 years, 12 months ago) |
|
Kdawg wrote: | How is a PHP if statment formated, like if $game = North Royaltin then $game = North_Royaltin? |
You want this:
Code: |
if($game=="North Royaltin") $game="North_Royaltin";
|
|
________________________________ Iyonix |
|
|
|
adam
Forum Moderator & Developer
Joined: 26 Jul 2002
Posts: 704
Location: UK
|
Posted:
Sun Apr 27, 2003 9:33 am (20 years, 12 months ago) |
|
lol...so many different ways of writing the same thing. |
________________________________ It's turtles all the way down... |
|
|
|
Kdawg
Senior WebHelper
Joined: 21 Apr 2003
Posts: 153
|
Posted:
Tue May 13, 2003 8:57 pm (20 years, 11 months ago) |
|
How do I use or in an if statment like
if ($number == '1' or $number == '2') {
function_to_run();
} |
|
|
|
|
SfCommand
Senior WebHelper
Joined: 10 Nov 2002
Posts: 143
Location: UK
|
Posted:
Tue May 13, 2003 9:04 pm (20 years, 11 months ago) |
|
|
|
|
Kdawg
Senior WebHelper
Joined: 21 Apr 2003
Posts: 153
|
Posted:
Tue May 13, 2003 9:06 pm (20 years, 11 months ago) |
|
It worked the way I had it, lol. I guess I should test it before I ask. |
|
|
|
|
jayant
Team Member
Joined: 07 Jan 2002
Posts: 262
Location: New Delhi, India
|
Posted:
Thu May 15, 2003 3:00 pm (20 years, 11 months ago) |
|
|
|
|
|
Page generation time: 0.166315 seconds :: 18 queries executed :: All Times are GMT
Powered by
phpBB 2.0
© 2001, 2002 phpBB Group :: Based on an FI Theme