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

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

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

    Default

    DAY 2 PROGRAMMING

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

    My Code is as follows:
    Code:
    <?php
    
    $actorName1 = '<b>Mohanlal</b>';
    $actorName2 = '<b>Mammootty</b>';
    $actorName3 = '<b>Suresh Gopi</b>';
    
    $award = '<b>National Film Awards</b>';
    
    $Times1 = 3;
    $Times2 = 1;
    
    echo 'Actor ' . $actorName1 . ' and '  . $actorName2 . ' received ' . $award . ' ' . $Times1 . ' times'; echo '.';
    
    echo '<br> <br>';
    
    echo 'But ' . $actorName3 . ' received it only ' . $Times2 . ' time'; echo '.';

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

    Default

    Quote Originally Posted by vineesh View Post
    http://php.flashwebhost.com/vineesh/...ariables_2.php

    I was facing difficulty to insert a full stop after a sentence. But I managed to make it work. My code is

    Code:
    <?php
    
    $staffName = 'Ramesh';
    $companyName = 'HOSTONNET';
    
    $staffName2 = 'Suresh';
    
    $staffName3 = 'Tom';
    
    echo $staffName . ' is working in ' . $companyName;  echo '.'; echo ' But '; echo $staffName2; echo ' not.' ;
    
    echo '<br>';
    
    echo $staffName3 . ' also working in ' . $companyName . 'for the past 10 years'; echo '.';
    Is there any issue with this ?

    Try this

    Code:
    <?php
    
    $staffName = 'Ramesh';
    $companyName = 'HOSTONNET';
    
    $staffName2 = 'Suresh';
    
    $staffName3 = 'Tom';
    
    echo $staffName . ' is working in ' . $companyName .  '.' .  ' But ' .  $staffName2 . ' not.' ;
    
    echo '<br>';
    
    echo $staffName3 . ' also working in ' . $companyName . ' for the past 10 years.';
    You can also replace

    Code:
    echo $staffName . ' is working in ' . $companyName .  '.' .  ' But ' . $staffName2 . ' not.' ;
    
    echo '<br>';
    
    echo $staffName3 . ' also working in ' . $companyName . ' for the past 10 years.';
    With

    Code:
    echo '<p>' . $staffName . ' is working in ' . $companyName .  '.' .  ' But ' .  $staffName2 . ' not.</p>' ;
    
    echo '<p>' . $staffName3 . ' also working in ' . $companyName . ' for the past 10 years.</p>';
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

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

    Default

    Quote Originally Posted by image View Post
    DAY 2 PROGRAMMING

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

    Code:
    <?php
    
    
    $MovieName = '<b>Mr. Fraud</b>';
    
    
    echo 'Mohanlal\'s Upcoming Movie '  .  $MovieName;
    Variable names always start with smaller case letter.

    Code:
    <?php
    
    
    $movieName = '<b>Mr. Fraud</b>';
    
    
    echo 'Mohanlal\'s Upcoming Movie '  .  $movieName;
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

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

  5. #25
    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.

  6. #26
    Join Date
    May 2014
    Posts
    21

    Default

    Quote Originally Posted by annie View Post
    I got an error while adding break in http://php.flashwebhost.com/annie/company.php

    Code:
    Parse error:  syntax error, unexpected '>' in /home/fwhphp/public_html/annie/company.php on line 3 
    Code:
     <?php
    $companyname = 'Relience';
    echo $companyname <br> ; 
    $companyname = 'Whirpool'; 
    echo $companyname ;
    Use a concat operator after $companyname and also put the <br> in quotes ($companyname.'<br>'; )

    Code:
    <?php$companyname = 'Relience';
    echo $companyname.'<br>'; 
    $companyname = 'Whirpool'; 
    echo $companyname ;

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

    Default

    DAY 2 VARIABLES EXAMPLE 4

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

    My code is
    Code:
    <?php
    
    $numActors = 15;
    $numActress = 12;
    $number1 = 5; 
    $number2 = 10;
    $number3 = 15;
    
    echo '<p>' . 'Number of Actors ' . '= ' . $numActors . '</p>';
    
    echo '<p>' . 'Number of Actress ' . '= ' . $numActress . '</p>';
    
    echo '<p>' . 'Total number of film stars' . ' = ' . ($numActors + $numActress) . '</p>';
    
    echo '<br> <br>';
    
    echo '<p>' . 'The sum of ' . $number1 . ' + ' . $number2 . ' is ' . '= ' . $number3 . '</p>';

  8. #28
    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) ;

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

    Default

    DAY 2 VARIABLES POST 3


    http://php.flashwebhost.com/ramesh/study3.php

    Code:
    <?php
    
    $film = 'Gangster';
    
    echo  'Film: ' . $film; echo '. <br>';
    
    $actor = 'Mammootty';
    
    echo  'Actor: ' . $actor; echo '. <br>';
    
    $actress = 'Nyla Usha';
    
    echo  'Actress: ' . $actress; echo '. <br>';
    
    $director = 'Aashiq Abu';
    
    echo  'Director: ' . $director; echo '. <br><br>'; 
    
    $actress1 = 'Aparna Gopinath';
    
    
    echo 'The ' . $film . ' is a Malayalam film , '  . $film . ' directed by ' . $director . ', ' . $actor . ' plays the lead role as Akbar Ali Khan'; echo '.';
    
    echo '<br> <br>';
    
    echo 'Along with ' . $actress . ' and ' . $actress1 . ' as the female leads'; echo '.';

  10. #30
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    DAY 2 PHP PROGRAMMING

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

    Code:
    <?php
    
    
    $priceOfMobile = '2500' ;
    $numOfMobile = '10' ;
    
    
    echo ' Price of ' . $numOfMobile . ' Mobiles = Rs: ' . ($priceOfMobile*$numOfMobile) . '.00 /- ' ;

Page 3 of 5 FirstFirst 12345 LastLast

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
  •