If statements within If statements

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fatalkaiser
Forum Newbie
Posts: 2
Joined: Sun Apr 22, 2007 7:35 pm

If statements within If statements

Post by fatalkaiser »

Jcart | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


How do i do it?

What im trying to do looks something like this

Code: Select all

<?php 
if ($variable == "blah") 
(
	if ($variable2 == "blahblah")
	{
	$a = 1;
	$b = 2;
	$c = 3;
	};
	
	else 
	{
	$a = 2;
	$b = 3;
	$c = 4;
	};
)
else
                {
	echo "blah"; 
	};
?>

Can someone give me the correct coding for this?


Jcart | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Your using normal brackets () instead of curly {} in the first if statement.
fatalkaiser
Forum Newbie
Posts: 2
Joined: Sun Apr 22, 2007 7:35 pm

Post by fatalkaiser »

Thanx a lot!
That was the last little bug in my script and now it works perfectly. You guys are great here :) Keep up the good work
User avatar
the_last_tamurai
Forum Commoner
Posts: 87
Joined: Wed Feb 28, 2007 8:24 am
Location: cairo
Contact:

Post by the_last_tamurai »

delete the semi-colons ';' after the curly brackets '}'
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

the_last_tamurai wrote:delete the semi-colons ';' after the curly brackets '}'
Those are actually valid :wink:
User avatar
the_last_tamurai
Forum Commoner
Posts: 87
Joined: Wed Feb 28, 2007 8:24 am
Location: cairo
Contact:

Post by the_last_tamurai »

thanx , I didnt know that, but is it a recommended coding style??? just a question :?:
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Personal preference.. although I rarely see it being used. This is probably the 2nd time I've seen someone use it.
Post Reply