Thread: My First php script

Results 1 to 6 of 6
  1. #1 My First php script 
    Banned...Not

    DJ Cheetos's Avatar
    Join Date
    Aug 2008
    Age
    26
    Posts
    859
    Thanks given
    2
    Thanks received
    4
    Rep Power
    708
    A nice simple welcoming script could be used for companies or w/e

    [php]<html>
    <body>

    <?php
    $d=date("D");
    if ($d=="Sun")
    echo "Have a nice Sunday!";
    elseif ($d=="Mon")
    echo "Have a nice Monday!";
    elseif ($d=="Tue")
    echo "Have a nice Tuesday!";
    elseif ($d=="Wed")
    echo "Have a nice Wednesday!";
    elseif ($d=="Thu")
    echo "Have a nice Thursday!";
    elseif ($d=="Fri")
    echo "Have a nice Friday!";
    elseif ($d=="Sat")
    echo "Have a nice Saturday!";
    ?>

    </body>
    </html>[/php]

    I've used a tutorial for making this but i learnt something from it (else if statements - date thing)
    Reply With Quote  
     

  2. #2  
    is serisiuly cul.

    DJ Dan's Avatar
    Join Date
    Apr 2007
    Posts
    1,324
    Thanks given
    6
    Thanks received
    5
    Rep Power
    223
    [PHP]
    <?php
    echo "Have a nice " . date("l");
    ?>
    [/PHP]

    No reason for all that, [Only registered and activated users can see links. ]

    That should help
    Reply With Quote  
     

  3. #3  
    cookie monsta
    Guest
    [PHP]<?php
    $d=date("D");
    switch ($d) {
    case "mon":
    echo "";
    break;

    case "tue":
    echo "";
    break;

    case "wed":
    echo "";
    break;

    case "thu":
    echo "";
    break;

    case "fri":
    echo "";
    break;

    case "sat":
    echo "";
    break;

    case "sun":
    echo "";
    break;

    default:
    echo "lulwut?";
    break;
    }
    ?> [/PHP]
    its better then over using the if and else and elseif lol how long you been learning for
    Reply With Quote  
     

  4. #4  
    is serisiuly cul.

    DJ Dan's Avatar
    Join Date
    Apr 2007
    Posts
    1,324
    Thanks given
    6
    Thanks received
    5
    Rep Power
    223
    Lol cookie monsta it wouldn't work.

    You have $d as the date, And the in the switch you have $date.
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Nov 2006
    Posts
    699
    Thanks given
    1
    Thanks received
    32
    Rep Power
    524
    Quote Originally Posted by cookie monsta View Post
    [PHP]<?php
    $d=date("D");
    switch ($d) {
    case "mon":
    echo "";
    break;

    case "tue":
    echo "";
    break;

    case "wed":
    echo "";
    break;

    case "thu":
    echo "";
    break;

    case "fri":
    echo "";
    break;

    case "sat":
    echo "";
    break;

    case "sun":
    echo "";
    break;

    default:
    echo "lulwut?";
    break;
    }
    ?> [/PHP]
    its better then over using the if and else and elseif lol how long you been learning for
    [PHP]<?php
    $d=date("D");
    switch ($d) {
    case "mon":
    case "tue":
    case "wed":
    case "thu":
    case "fri":
    case "sat":
    case "sun":
    echo "";
    break;

    default:
    echo "lulwut?";
    break;
    }
    ?>[/PHP]

    You obviously haven't learned about passing one case onto the next if you're going to do the same snippet of code for two or more of the same cases.
    Reply With Quote  
     

  6. #6  
    Banned...Not

    DJ Cheetos's Avatar
    Join Date
    Aug 2008
    Age
    26
    Posts
    859
    Thanks given
    2
    Thanks received
    4
    Rep Power
    708
    Quote Originally Posted by cookie monsta View Post
    its better then over using the if and else and elseif lol how long you been learning for
    It's ma first day
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

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