Page 1 of 2 12 LastLast
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
    Sep 2003
    Posts
    3,040

    Default

    Quote Originally Posted by annie View Post
    http://php.flashwebhost.com/annie/cow_can_fly.php

    Code:
    <?php
    $cowsCanFly = 'no'; //try changing value to 'no'
    
    if  ($cowsCanFly == 'yes' )
    
    { echo 'There is no time like the present '; }
    
    if ($cowsCanFly == 'no' )
    
    { echo 'When in Rome, do as the Romans'; }
    Code formatting is not proper.

    Code:
    <?php
    
    $cowsCanFly = 'no'; //try changing value to 'no'
    
    if  ($cowsCanFly == 'yes' ) {
       echo 'There is no time like the present '; 
    }
    
    if ($cowsCanFly == 'no' ) { 
        echo 'When in Rome, do as the Romans'; 
    }
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  2. #2
    Join Date
    May 2014
    Posts
    21

    Default

    http://php.flashwebhost.com/austin/day4.php

    Code:
    <?php$animal = 'tiger';
    $color = 'green';
    
    
    if($animal == 'frog'){
    	if($color=='green'){
    		echo 'You are green frog';
    	}
    	else
    		echo 'You are an invisible frog';
    }
    
    
    else if($animal=='dragon'){
    
    
    	if($color == 'green')
    		echo 'You are a green dragon and stefin got your eggs :D';
    
    
    	else if($color=='red')
    		echo ' You are a red dragon and stefin is coming to steal ur eggs too :D';
    }
    
    
    else{
    	echo 'i know you are a tiger and you are green.';
    }
    Stefin ... run!!!!

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

    Default

    Quote Originally Posted by Austinwhite View Post
    http://php.flashwebhost.com/austin/day4.php

    Code:
    <?php$animal = 'tiger';
    $color = 'green';
    
    
    if($animal == 'frog'){
    	if($color=='green'){
    		echo 'You are green frog';
    	}
    	else
    		echo 'You are an invisible frog';
    }
    
    
    else if($animal=='dragon'){
    
    
    	if($color == 'green')
    		echo 'You are a green dragon and stefin got your eggs :D';
    
    
    	else if($color=='red')
    		echo ' You are a red dragon and stefin is coming to steal ur eggs too :D';
    }
    
    
    else{
    	echo 'i know you are a tiger and you are green.';
    }
    Stefin ... run!!!!

    Good code, use { } even if it is only one line code, lets have some coding style everyone follow, so no one (me) get confused
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

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

    Default

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

    Code:
    <?php
    
    $ticket = 'no';
    
    if ($ticket == 'yes') {
    
    echo 'We will get ticket' ;
    
    }
    
    if ($ticket == 'no') {
    
    echo 'We will not get ticket' ;
    
    }
    ------------------------
    http://php.flashwebhost.com/vineesh/...n_making_2.php
    Code:
    <?php
    
    $mark = 99;
    
    if ($mark == 99) {
    
    echo 'You have got 99 marks, you win!';
    
    }
    
    if ($mark == 19) {
    
    echo 'Sorry, You are failed';
    
    }

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

    Default

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

    and my code is as follows:
    Code:
    <?php
    
    $passMark = 35;
    
    $student1Name = 'Manu';
    $student1Mark = 34;
    
    $student2Name = 'Saritha';
    $student2Mark = 60;
    
    $student3Name = 'Sudhi';
    $student3Mark = 93;
    
    $class1 = 'First Class';
    $class2 = 'Distinction';
    
    echo 'Passmark = ' . $passMark . '<br> <br>' ;
    
    echo 'Student names with marks <br> <br>';
    
    echo $student1Name . ' = ' . $student1Mark . ' marks. <br>' ;
    echo $student2Name . ' = ' . $student2Mark . ' marks. <br>' ;
    echo $student3Name . ' = ' . $student3Mark . ' marks. <br> <br>' ;
    
    if ($student1Mark < $passMark) {
    
    echo $student1Name . ', you have got only ' . $student1Mark . ' marks and you are failed. <br>' ;
    
    }
    
    if ($student2Mark > $passMark) {
    
    echo $student2Name . ', you have got ' . $student2Mark. ' marks and you passed with ' . $class1 . '<br>' ;
    
    }
    
    if ($student3Mark > $passMark) {
    
    echo 'Congratulations ! ' . $student3Name . '!. You have got ' . $student3Mark . ' marks and you passed with ' . $class2 ;
    
    }

  6. #6
    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.';
    
    
    }

  7. #7
    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.';
    
    
    }

  8. #8
    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 ?';
    
    }

  9. #9
    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.' ;
    
    
    }

  10. #10
    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.

Page 1 of 2 12 LastLast

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
  •