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.

Recommended Answers

All 3 Replies

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

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.

Thanks Makes more sense now with the PHP documentation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.