954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Case Help

I am pritty new to PHP and there are a lot of thinks i still dont know.

What the problem is that i dont understand the purpuse of the case statement another words what does it do and how u r suppose to use it.

ashneet
Junior Poster
147 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

Case by itself serves little or no purpose. I think you're looking for the switch function, instead.

Sp!ke
Light Poster
45 posts since Jul 2005
Reputation Points: 14
Solved Threads: 0
 

PHP's switch/case statement is like a big if/elseif/else statement. I use it all the time. I think the PHP documentation explains it well--not sure I can make it more clear.
http://www.php.net/manual/en/control-structures.switch.php

You don't have to use switch/case--you can use if/elseif/else instead, but switch/case is cleaner. Also, switch/case allows you to setup conditions where more than one test is true so multiple case sections fire--although I've never done this in my thousands of lines of PHP code.

Troy
Posting Whiz
362 posts since Jun 2005
Reputation Points: 36
Solved Threads: 6
 

Thanks Makes more sense now with the PHP documentation.

ashneet
Junior Poster
147 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You