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
    Feb 2007
    Posts
    26,214

    Default

    DAY 2 PHP PROGRAMMING

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

    Code:
    <?php
    
    
    $numOfBoys = '20' ;
    $numOfGirls = '25' ;
    
    
    echo 'Total number of students = ' . ($numOfBoys+$numOfGirls) ;
    Last edited by image; 05-09-2014 at 10:48 AM.

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

    Default

    Quote Originally Posted by image View Post
    DAY 2 PHP PROGRAMMING

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

    Code:
    
    <?php
    
    
    $numboys = '20' ;
    $numgirls = '25' ;
    
    
    echo 'Total number of students = ' . ($numboys+numgirls) ;

    This program have syntax error on line

    Code:
    echo 'Total number of students = ' . ($numboys+numgirls) ;
    $ missing for numgirls.

    Proper usage.

    Code:
    <?php
    
    $numBoys = 20;
    $numGirls = 25;
    
    echo 'Total number of students = ' . ($numBoys + $numGirls) ;
    Only strings values need to be enclosed within quotes (' or ").

    Variable names, if two words, Capitalize first letter of 2nd, 3rd, etc.. word.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

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
  •