Results 1 to 3 of 3

Thread: PHP 'switch' statement

Hybrid View

  1. #1
    Senior Member
    Join Date
    Apr 2004
    Posts
    228

    PHP 'switch' statement

    Hi guys

    I'm a bit confused with the 'switch' statement.

    The main thing I need to know is whether it takes multiple agruments like:

    switch ($one, $two, $three) {

    case $one == 1;

    case $two == 2;

    case $three == 3;

    }


    or will it be to write it:

    switch (TRUE){

    case $one == 1;

    case $two == 2;

    case $three == 3;

    }


    I've seen the second example in the comments to some tutorials.
    Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying

  2. #2
    Junior Member
    Join Date
    May 2005
    Posts
    11
    Hi,

    The switch statement can only be used to compare the value of one variable.
    And it is used in this way: http://pt.php.net/switch
    If you want to check the value of multiple vars use the if statement.
    -

  3. #3
    Senior Member
    Join Date
    Apr 2004
    Posts
    228
    Quote Originally Posted by hknetmaster
    Hi,

    The switch statement can only be used to compare the value of one variable.
    And it is used in this way: http://pt.php.net/switch
    If you want to check the value of multiple vars use the if statement.

    Well, I thought about it, but then decided to research switch as well, as it might come useful

    I also read a number of tutorials on the subject, but in my experience these are always writen as simple as possible and it's hard to find anything to advanced without asking on the forums such as this one
    Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying

Similar Threads

  1. Apache, PHP, MySQL with basic security settings.
    By nightcat in forum The Security Tutorials Forum
    Replies: 9
    Last Post: May 28th, 2005, 02:47 AM
  2. PHP Flaws
    By SDK in forum Web Security
    Replies: 19
    Last Post: December 20th, 2004, 05:31 PM
  3. Tutorial: Apache 2.0.49 and PHP 4.3.7!
    By Vorlin in forum Other Tutorials Forum
    Replies: 3
    Last Post: June 15th, 2004, 10:25 PM
  4. Installing Apache and PHP on Linux
    By HDD in forum Other Tutorials Forum
    Replies: 2
    Last Post: February 1st, 2004, 08:05 PM
  5. The Worlds Longest Thread!
    By Noble Hamlet in forum AntiOnline's General Chit Chat
    Replies: 1100
    Last Post: March 17th, 2002, 09:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •