Results 1 to 10 of 50

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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);

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

  3. #3
    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)). '/-';

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

  5. #5
    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)). '/-';

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
  •