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
    May 2014
    Posts
    21

    Post 1 doubt

    PHP Code:
    <?php

    $name
    'crazyfrog';
    $action ' is coming to town.';
    $n1 8;
    $n2=9;

    echo 
    $name.$action;
    echo 
    '<br>';
    echo 
    '8 + 9 = ' . ($n1+$n2);
    echo 
    '<br>' . (8*9);
    1 doubt

    does php use any preference rules from maths?
    like BODMAS (Bracket, of, division, multiplication, addition, subtraction) rule or something?
    when echoed does the compiler compiles the things in bracket first?

    i had an error when i omitted the bracket of 8*9
    PHP Code:
    echo '<br>'.(8*9); 
    had error with this code.
    PHP Code:
    echo '<br>'.8*9
    Last edited by Austinwhite; 05-09-2014 at 12:18 PM. Reason: spellling error

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

    Default

    @Austinwhite Please don't ask too much complicated maths questions. No one here understand BODMAS or preference rules from maths

    PHP Code:
    echo '<br>'.8*9
    I think PHP is confused about that to do here. So it is better use brackets when you use maths operation.
    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
  •