Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 33
  1. #11
    Join Date
    Sep 2008
    Location
    UK
    Posts
    3,670
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Hypertext View Post
    switch isn't a function.

    :rolleyes:

    If your going to make a tutorial, at least code it well, indentation, having default at the bottom, using strings in your get array.

    oh denta just said the exact same thing... thats like a teacher teaching you to code in tables -- you shouldn't do it.
    Statement then. default can go anywhere it wants, I prefer it at the top because it's much more easier to organize my cases:rolleyes:
    Back for a while.

  2. #12
    Join Date
    May 2005
    Location
    Burgessville
    Posts
    806
    Tokens
    0

    Default

    I'm pretty sure theres an easier way to do this same thing.. with less code. but i maybe wrong.. **looks on computer for it**

    Originally Posted by bananasislegend
    this thread might be better than sex..

  3. #13
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    (23:20) James -> Nicole: $_GET[page]
    (23:20) James -> Nicole: what a ...
    (23:21) James -> Nicole: wops
    (23:21) James -> Nicole: i usually look at the bottom 4 the default
    (23:21) TehUpload: same
    (23:21) TehUpload: that's where it goes
    (23:21) TehUpload: because it says
    (23:21) TehUpload: if it is this, bla.
    if it is this, bla.
    if it isn't either one, bla (default)
    (23:21) TehUpload: not
    (23:22) TehUpload: if it is neither one, bla (default)
    if it is this, bla.
    convo with Celeb and I, talking about this.
    Hi, names James. I am a web developer.

  4. #14
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    PHP Code:
    switch($_GET ["type"]) {
        case 
    "about" :
            
    $core->template->parseTemplate"about" );
            break;
        
        case 
    "contact" :
            
    $core->template->parseTemplate"contact" );
        
        default :
            
    $core->template->parseTemplate"index" );
            break;


  5. #15
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Quote Originally Posted by Dentafrice View Post
    PHP Code:
    switch($_GET ["type"]) {
        case 
    "about" :
            
    $core->template->parseTemplate"about" );
            break;
        
        case 
    "contact" :
            
    $core->template->parseTemplate"contact" );
        
        default :
            
    $core->template->parseTemplate"index" );
            break;

    That would parse 2 templates when you use contact.


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  6. #16
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    oops forgot that break.

    PHP Code:
    switch($_GET ["type"]) {
        case 
    "about" :
            
    $core->template->parseTemplate"about" );
            break;
        
        case 
    "contact" :
            
    $core->template->parseTemplate"contact" );
            break;
        
        default :
            
    $core->template->parseTemplate"index" );
            break;


  7. #17
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Obviously as pointed out above you can drop-through cases, e.g:

    PHP Code:
    switch( $_GET['act'] )
    {
        case 
    'lol':
        case 
    'what':
        case 
    'thing':
            echo(
    'lol');
            break;
            
        default:
            echo(
    'default');
            break;

    case "lol" would drop through what and thing and echo lol, so would what, and also thing.


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  8. #18
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Pointing out above, expanding what Dan said, you can use default and index as the same way, and drop-through the cases.

  9. #19
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    Caleb correct me if I'm wrong, isn't it bad to have spacing like

    $_GET ["var"]

    Between the T and square left bracket? I don't know...

    I think we should try and conform to pear.php.net's standards, they are quite good. I'm sick of everybody adding whitespace and parenthesis EVERYWHERE to make it look 'pretty'..

    Whitespace and unecessary characters should only be used where it makes it easier to read, and less to type, IMO.
    How could this hapen to meeeeeeeeeeeeeee?lol.

  10. #20
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    I don't type the spaces, I don't type any of the formatting.

    I have a nice little too called Ctrl+Shift+F which does it all for me, to phpDoc standards.. which are highly acceptable

    pear's standards are laughed at, and are only used for pear repository coding, not a standard for coding.

Page 2 of 4 FirstFirst 1234 LastLast

Posting Permissions

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