Results 1 to 10 of 42

Thread: Day 4 - Decision Making - Become PHP Expert in 30 days

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2009
    Posts
    76,596

    Default

    http://php.flashwebhost.com/sherly/abc.php

    Code:
    Parse error:  syntax error, unexpected '{' in /home/fwhphp/public_html/sherly/abc.php on line 5
    Code:
    <?php
    
    if ($a > $b) {
        echo 'a is bigger than b';
    }  esle  if ($a == $b)  {
       echo 'a is equal to b';
    }  else  ($a < $b) {
       echo 'a is smaller than b';
    }
    Last edited by sherlyk; 05-13-2014 at 07:04 AM.

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

    Default

    Quote Originally Posted by sherlyk View Post
    http://php.flashwebhost.com/sherly/abc.php

    Code:
    Parse error:  syntax error, unexpected '{' in /home/fwhphp/public_html/sherly/abc.php on line 5
    Code:
    <?php
    
    if ($a > $b) {
        echo 'a is bigger than b';
    }  esleif ($a == $b)  {
       echo 'a is equal to b';
    }  else  ($a < $b) {
       echo 'a is smaller than b';
    }
    First of all, where did you set $a and $b ? With out such a variable how it works ?

    The error is because

    esleif
    Spelling mistake, use else if

    Fixed code


    Code:
    <?php
    
    $a = 1;
    $b = 100;
    
    if ($a > $b) {
        echo 'a is bigger than b';
    }  else if ($a == $b)  {
       echo 'a is equal to b';
    }  else  ($a < $b) {
       echo 'a is smaller than b';
    }
    
    echo '<p>Value of $a = ' . $a . ' and value of $b = ' . $b . '</p>';
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

Tags for this Thread

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
  •