Page 3 of 5 FirstFirst 12345 LastLast
Results 21 to 30 of 42

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

  1. #21
    Join Date
    Nov 2009
    Posts
    76,596

    Default

    http://php.flashwebhost.com/sherly/discount.php

    Code:
    <?php 
     $over65=true; 
     $price = 3.00; 
     if ($over65) 
     { 
     $discount =.90; 
    echo  "You have received our senior's discount, your price is $" . $price*$discount; 
     } 
     else 
     { 
    echo "Sorry you do not qualify for a discount, your price is $" . $price; 
     } 
     ?>
    Last edited by sherlyk; 05-13-2014 at 07:30 AM.

  2. #22
    Join Date
    Nov 2004
    Location
    India
    Posts
    65

    Default

    http://php.flashwebhost.com/stefin/fish_can_fly.php

    Code:
    <?php
    $fishsCanFly = 'yes';
    if ($fishsCanFly == 'yes') {
    echo 'then we can never have a fish curry' ;
     }
    if ( $fishsCanFly == 'no') {
    echo 'then we can have as much fish as we want' ;
     }

  3. #23
    Join Date
    Nov 2004
    Location
    India
    Posts
    65

    Default

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

    Code:
    <?php
    $totalScoreRequiredToUnlockTheNextLevel = 8000;
    $playerName = 'stefin';
    $yourScore = 16000;
    if ($yourScore > $totalScoreRequiredToUnlockTheNextLevel) {
    echo 'Congratulations ' . $playerName . ' ! hurrah You Have Cleared The Level your score is' .  $yourScore . ' point' 
    ;  
    }

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

    Default

    Quote Originally Posted by stefin View Post
    http://php.flashwebhost.com/stefin/if_greater.php

    Code:
    <?php
    $totalScoreRequiredToUnlockTheNextLevel = 8000;
    $playerName = 'stefin';
    $yourScore = 16000;
    if ($yourScore > $totalScoreRequiredToUnlockTheNextLevel) {
    echo 'Congratulations ' . $playerName . ' ! hurrah You Have Cleared The Level your score is' .  $yourScore . ' point' 
    ;  
    }

    You win, dragon eggs are on the way
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

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

    Default

    Quote Originally Posted by stefin View Post
    http://php.flashwebhost.com/stefin/fish_can_fly.php

    Code:
    <?php
    $fishsCanFly = 'yes';
    if ($fishsCanFly == 'yes') {
    echo 'then we can never have a fish curry' ;
     }
    if ( $fishsCanFly == 'no') {
    echo 'then we can have as much fish as we want' ;
     }
    Nice program, fishes love water.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  6. #26
    Join Date
    May 2014
    Posts
    21

    Lightbulb = and ==

    Quote Originally Posted by melbin View Post
    http://php.flashwebhost.com/melbin/days.php

    PHP Code:
    <?php
    $day
    ='Sunday';
    if (
    $day="Sunday") {
        echo 
    'Have a nice Sunday';
    }

    else {
        echo 
    'Have a nice day';
    }
    In this code when i use == on line no:3 i am getting the result as FALSE. Why ?

    Doubt 2

    Is it possible to get the day by using PHP date and time function ?
    i used ur code and found no error even when i used == in line 3.

    and
    Code:
    if ($day="Sunday")
    is a wrong code. bez in this you are give $day the value "Sunday",and in this case the if-statement will be always executed.

    check as
    Code:
    if($day = 'monday')
    in this code too the if statement will be execute bez all you doing is telling the compiler that the value of $day variable is now 'monday' and not to check if $day is equal to 'monday'.

    x == y;
    tells the compiler to check if left hand side (x) of [ == ] is equal to the right hand side (y).

    x=y;
    tells the compiler that now the value of y is to given to x also.

    i think the point is clear..

  7. #27
    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!!!!

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

    Default

    Quote Originally Posted by Austinwhite;287099[code
    if($day = 'monday')[/code]
    in this code too the if statement will be execute bez all you doing is telling the compiler that the value of $day variable is now 'monday' and not to check if $day is equal to 'monday'.
    You explained it better than me
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  9. #29
    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.

  10. #30
    Join Date
    Feb 2005
    Location
    India
    Posts
    11,004

    Default

    Quote Originally Posted by admin View Post
    You explained it better than me
    Got it.. Thank you Admin and Austin.
    VIDEO WORLD : LATEST HOLLYWOOD || BOLLYWOOD || SOUTH INDIAN VIDEOS || TRAILERS

Page 3 of 5 FirstFirst 12345 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
  •