Results 1 to 10 of 42

Thread: Day 4 - Decision Making - Become PHP Expert in 30 days

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    DAY 4 PHP PROGRAMMING

    http://php.flashwebhost.com/tom/trai..._Ernakulam.php

    Code:
    <?php
    
    
    $trainGoesToErnakulam = 'no';
    
    
    if ($trainGoesToErnakulam == 'yes')
    
    
    {
    
    
    echo 'I Will Enter The Train.';
    
    
    }
    
    
    if ($trainGoesToErnakulam == 'no')
    
    
    {
    
    
    echo 'I Will Not Enter The Train.';
    
    
    }

  2. #2
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    DAY 4 PHP PROGRAMMING

    http://php.flashwebhost.com/tom/if_greater.php

    Code:
    <?php
    
    
    $passMark = '35';
    
    
    $studentName = 'Tom';
    
    
    $studentMark = '60';
    
    
    if ($studentMark>$passMark) 
    
    
    {
    
    
    echo 'Congratulations '. $studentName . ' ! You passed exam with ' . $studentMark . ' marks.';
    
    
    }

  3. #3
    Join Date
    Oct 2003
    Location
    Kochi, Kerala, India
    Posts
    21,389

    Default

    http://php.flashwebhost.com/vineesh/...n_making_5.php

    Code:
    <?php
    
    $rain = 'eeeee';
    
    if ($rain == 'yes') {
    
    echo 'It will rain today.'; 
    
    }
    
    else if ($rain == 'no') {
    
    echo 'It will not rain today.'; 
    
    }
    
    else {
    
    echo 'huh...what is this ?';
    
    }

  4. #4
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    DAY 4 PHP PROGRAMMING

    http://php.flashwebhost.com/tom/if_else_greater.php

    Code:
    <?php
    
    
    $passMark = '35';
    $studentName = 'Tom';
    $studentMark = '30';
    
    
    if ($studentMark > $passMark) {
    echo 'Congratulations '. $studentName . ' ! You passed exam with ' . $studentMark . ' marks.';
    
    
    } else {
    
    
    echo ' Sorry! You failed. Good luck next time.' ;
    
    
    }

  5. #5
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    DAY 4 PHP PROGRAMMING

    http://php.flashwebhost.com/tom/if_else_greater_bug.php

    Code:
    <?php
    
    $passMark = '35';
    $studentName = 'Tom';
    $studentMark = '35';
    
    
    if ($studentMark >= $passMark) {
    
    
    echo 'Congratulations ' . $studentName . ' ! You passed exam with ' . $studentMark . ' marks' ;
    
    
    }
    
    
    else
    
    
    {
    
    
    echo 'Sorry! You failed. Good luck next time.' ;
    
    
    }
    Last edited by vineesh; 05-14-2014 at 11:31 AM.

  6. #6
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    DAY 4 PHP PROGRAMMING

    http://php.flashwebhost.com/tom/cow_version_2.php

    Code:
    <?php
    
    
    $trainGoesToErnakulam = 'when';
    
    
    if ($trainGoesToErnakulam == 'yes') {
    
    
    echo 'I Will Enter The Train.'; }
    
    
    else if ($trainGoesToErnakulam == 'no') 
    
    
    {
    
    
    echo 'I Will Not Enter The Train.';
    
    
    }
    
    
    else
    
    
    {
    
    
    echo 'I will go at 11 AM.';
    
    
    }

  7. #7
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    { and } not properly aligned in tom and vineesh's codes. It should be like

    Code:
    if (CONDITION) {
        // do some thing if true
    } else {
       // do another thing
    }
    It is OK, just coding style, it is better to follow proper coding style from the beginning.

    Variable names are perfect.

    Updated code for

    http://php.flashwebhost.com/vineesh/...n_making_5.php

    Code:
    <?php
    
    $rain = 'eeeee';
    
    if ($rain == 'yes') {
        echo 'It will rain today.'; 
    } else if ($rain == 'no') {
        echo 'It will not rain today.'; 
    } else {
        echo 'huh...what is this ?';
    }
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  8. #8
    Join Date
    Jan 2008
    Location
    india,kerala-god's own country
    Posts
    14,007

    Default

    PHP PROGRAMING DAY - 4 MY 1'ST CODE

    http://php.flashwebhost.com/ramesh/d..._is_better.php

    Code:
    <?php
    
    $sachinisbetter = 'yes';
    
    if ($sachinisbetter =='yes'){
        echo 'Sachin is a great cricketer. He is better than Lara';
    }
    
    echo '<br>';
    
    $laraisbetter = 'no';
    
    if ($laraisbetter == 'yes'){
    echo 'Lara is better than sachin';
    }
    Last edited by rameshxavier; 05-15-2014 at 10:27 AM.

  9. #9
    Join Date
    Jan 2008
    Location
    india,kerala-god's own country
    Posts
    14,007

    Default

    PHP PROGRAMING DAY - 4 THIS IS MY 2'ND CODE

    http://php.flashwebhost.com/ramesh/day-4/if_greater.php

    PHP Code:
    <?php

    $laras_hundreds 
    54;

    $sachins_hundreds 100;

    $name_of_indian_cricketer ='Sachin';

    $name_of_westindian_cricketer ='Lara';

    if (
    $sachins_hundreds $laras_hundreds) {
        echo 
    'Congratulations ' $name_of_indian_cricketer '! You are better than Lara because you took '
        
    $sachins_hundreds ' centuries. ' $name_of_westindian_cricketer ' took 54 centuries only';
    Last edited by rameshxavier; 05-15-2014 at 10:32 AM.

  10. #10
    Join Date
    Sep 2003
    Location
    india
    Posts
    11,527

    Default

    http://php.flashwebhost.com/annie/if_else.php

    PHP Code:
    <?php

    $winningScore 
    200;

    $playerName 'Mariya';

    $palyerScore 240;

    if (
    $palyerScore $winningScore) {
       echo 
    'Congratulation ' $playerName '! You got ' $palyerScore ' Points. The minimum score is  ' $winningScore' . You are selected for next level.';
    } else { 
      echo 
    'Sorry!, Try again';
    }

Tags for this Thread

Bookmarks

Posting Permissions

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