Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 18
  1. #1
    Senior Member leprechaun13's Avatar
    Join Date
    May 2005
    Location
    Northampton
    Posts
    487
    Member #
    10058
    Using the following switch statement on my site

    PHP Code:
    <?php
    switch (@$_GET['page']):
        case 
    "home":
            include 
    'inc/home.php';
        break;
        case 
    "tanks":
            include 
    'inc/tanks.php';
        break;
        case 
    "resume":
            include 
    'inc/resume.php';
        default:
            include 
    'inc/home.php';
        break;
        endswitch;
    ?>
    and cant figure out why on the resume page it inclues my resume and my homepage content.
    Regards Phil,


  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    You forgot to break after the resume case.

  4. #3
    Senior Member leprechaun13's Avatar
    Join Date
    May 2005
    Location
    Northampton
    Posts
    487
    Member #
    10058
    ahhh got it cheers
    Regards Phil,


  5. #4
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Erm, I know it's personal preference, but why do some people like to use the alternative syntaxes instead of simple brackets? So it's obvious what the bracket belongs to?
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  6. #5
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    < shrug >. PHP is a bit of a swiss army knife in many ways -- jack of all trades, master of none, as it were. It really depends on where you come from. If you come from the Java/C/C++ world, you'll almost certainly use braces. If you come from, say, the Python world, or the BASH world (lol ), then maybe you'll prefer the other syntax.

    But personally, I always use curly braces. It's a nice uniform way of indicating things, and any good editor will highlight the paired brace for you.

  7. #6
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    My guess would be Visual Basic.

    There are benefits to both, but I'm with Shadowfiend. Braces just look cleaner.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  8. #7
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    I've used VB before, but used JS a lot more which led me to using curly braces (bless JS for its syntax flexibility over PHP)... and are there any editors at all that couple text-based closings?
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  9. #8
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Quote Originally Posted by Steax
    I've used VB before, but used JS a lot more which led me to using curly braces (bless JS for its syntax flexibility over PHP)... and are there any editors at all that couple text-based closings?
    I believe VB.NET 2005 couples text-based closings.

  10. #9
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Wait, JS for *its* syntax flexibility over PHP? Like what?

  11. #10
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Well I'm not sure about others, but I often enjoy the simplicity JS provides, especially when it comes to OOP (something I'm sure many will agree on). I've used JS for months utilizing arrays as parameters, etc. Most prominently with the weird way PHP works with accessing an object's member properties. In JS, "object.subobj.doThis()" seems totally logical, but the PHP method of "$object->doThis()" just sounds weird.
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:25 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com