Page 5 of 5 FirstFirst ... 345
Results 41 to 50 of 50

Thread: Day 2 - Variables - Become PHP Expert in 30 days

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

    Default

    DAY 2 PROGRAMMING .

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

    Code
    Code:
    <?php
    
    $costOfApple = 100;
    $costOfOrange = 70;
    $totalCost = $costOfApple + $costOfOrange;
    $discount = 0.2;
    
    
    echo 'Cost of Apple = Rs. ' . $costOfApple . ' /- <br>';
    echo 'Cost of Orange = Rs. ' . $costOfOrange . '/- <br>';
    echo 'Total Cost = Rs. ' . $totalCost . '/- <br>';
    echo 'Discount = Rs. ' . $totalCost * $discount . '/-  <br>' ;
    echo 'Cost after discount = Rs. ' . ( ( $totalCost ) - ( ($totalCost) * $discount )) . '/- <br>';

  2. #42
    Join Date
    Apr 2005
    Posts
    46,704

    Default

    http://php.flashwebhost.com/mini/variable_4.php

    Code:
     <?php
    
    
    $name = 'Raju';
    
    $place = 'Ernakulam';
    
    $job = 'Designer';
    
    $nation = 'india';
    
    $age = '30';
    
    echo $name . ' from ' .  $place . '. Working as ' . $job. '. Nationality ' . $nation . ' . Age ' . $age;

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

    Default

    Quote Originally Posted by minisoji View Post
    http://php.flashwebhost.com/mini/variable_4.php

    Code:
     <?php
    
    
    $name = 'Raju';
    
    $place = 'Ernakulam';
    
    $job = 'Designer';
    
    $nation = 'india';
    
    $age = '30';
    
    echo $name . ' from ' .  $place . '. Working as ' . $job. '. Nationality ' . $nation . ' . Age ' . $age;

    Code:
    $age = '30';
    Since age is numeric, no need to use single quote. For numeric values, use as follows

    Code:
    $age = 30;
    Everything else looks good.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  4. #44
    Join Date
    Apr 2005
    Posts
    46,704

    Default

    http://php.flashwebhost.com/mini/variable_4.php

    Code:
    <?php
    
    
    $name = 'Raju';
    
    $place = 'Ernakulam';
    
    $job = 'Designer';
    
    $nation = 'india';
    
    $age = 30;
    
    echo $name . ' from ' .  $place . '. Working as ' . $job. '. Nationality ' . $nation . ' . Age ' . $age;

  5. #45
    Join Date
    Apr 2005
    Posts
    46,704

    Default

    http://php.flashwebhost.com/mini/study.php

    Code:
    <?php
    
    
    $numoflilly = 50;
    $numofjasmin =30;
    
    echo 'Total number of flowers = '.($numoflilly+$numofjasmin);

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

    Default

    Quote Originally Posted by minisoji View Post
    http://php.flashwebhost.com/mini/study.php

    Code:
    <?php
    
    
    $numoflilly = 50;
    $numofjasmin =30;
    
    echo 'Total number of flowers = '.($numoflilly+$numofjasmin);
    Name of variables are difficult to understand. Use

    PHP Code:
    $numOfLilly 50;
    $numOfJasmin =30

    Variable name always start with smaller cause letter.

    If variable name have more than one word, capitalize first letter of each word.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

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

    Default

    DAY 2 PHP PROGRAMMING

    http://php.flashwebhost.com/ramesh/day-2/billing.php

    Code:
    <?php
    
    $mobile_price = 2500;
    $mobile_pouch = 300;
    $discount = 0.07; //7% discount.
    
    echo 'Total Cost = Rs: ' . ($mobile_price + $mobile_pouch) . '/-';
    echo'<br>';
    echo'Price After discount = Rs: ' . (($mobile_price + $mobile_pouch) - (($mobile_price + $mobile_pouch) * $discount)). '/-';

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

    Default

    Quote Originally Posted by rameshxavier View Post
    DAY 2 PHP PROGRAMMING

    http://php.flashwebhost.com/ramesh/day-2/billing.php

    Code:
    <?php
    
    $mobile_price = 2500;
    $mobile_pouch = 300;
    $discount = 0.07; //7% discount.
    
    echo 'Total Cost = Rs: ' . ($mobile_price + $mobile_pouch) . '/-';
    echo'<br>';
    echo'Price After discount = Rs: ' . (($mobile_price + $mobile_pouch) - (($mobile_price + $mobile_pouch) * $discount)). '/-';
    Variable naming is not proper.

    PHP Code:
    echo'<br>'
    Need a space after echo.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

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

    Default

    DAY 2 PHP PROGRAMMING - 2

    http://php.flashwebhost.com/ramesh/day-2/billing-2.php

    Code:
    <?php
    $cpu_price = 14000;
    $monitor_price = 8000;
    $discount = 0.12;
    $total_cost = $cpu_price + $monitor_price;
    
    echo 'Total cost = Rs: ' . $total_cost . '/-';
    echo '<br>';
    echo 'Price After Discount = Rs: '. ( $total_cost - ($total_cost * $discount)). '/-';

  10. #50
    Join Date
    Feb 2010
    Posts
    35

    Thumbs up 0+0

    PHP Code:
    <?php
    $zeroone 
    0;
    $zerotwo 0;
    echo 
    "0+0is" . ($zeroone+$zerotwo) ;
    ?>

Page 5 of 5 FirstFirst ... 345

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
  •