SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    why is php showing no error?

    I have PHP/Apache installation in Windows XP. the other day I noticed that code like this didn’t produce any errors.
    <?php
    print “Kailash”
    ?>
    you see, there was no semicolon to end the print statement. yet the code worked properly.
    why could be that?

    error_reporting level is E_ALL

  2. #2
    SitePoint Enthusiast webdude's Avatar
    Join Date
    Feb 2005
    Location
    Great Britain
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your quotation marks seem a bit special to me. I cut & pasted your script and tested it and I got this:
    “Kailash”

    I change the quotes and I get this:

    Kailash

    Now thats weird as for why you get no error? Don't know perhaps it's the same as this:

    PHP Code:
    <?php $var?>
    Which will echo whatever $var is. Don't why it's not reporting errors, but if it's not reporting one maybe there isn't one.

  3. #3
    SitePoint Enthusiast pento's Avatar
    Join Date
    Jan 2006
    Location
    Russia, Novosibirsk
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When you are using more than one line of code inside your php tags, you must separate each line with a semicolon [;]. Simply add one more piece of code to see parse error.
    GetDown->MakeLove();

  4. #4
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    php operators must always end with semicolon, but php parser allows you to omit the very last one.

    PHP Code:
    <?php
    print "one"; <-- mandatory
    print "two"; <-- optional
    ?>

  5. #5
    SitePoint Enthusiast pento's Avatar
    Join Date
    Jan 2006
    Location
    Russia, Novosibirsk
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by stereofrog
    php operators must always end with semicolon, but php parser allows you to omit the very last one.

    PHP Code:
    <?php
    print "one"; <-- mandatory
    print "two"; <-- optional
    ?>
    May be it's a bug ?
    GetDown->MakeLove();

  6. #6
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think so.

  7. #7
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Quote Originally Posted by stereofrog
    php operators must always end with semicolon, but php parser allows you to omit the very last one.
    OK. So that’s why it showed no error when I put a single line of code without semicolon

  8. #8
    SitePoint Wizard silver trophy Jelena's Avatar
    Join Date
    Feb 2005
    Location
    Universum, 3rd Corner
    Posts
    3,000
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pento
    May be it's a bug ?
    No, it's a feature.
    -- Jelena --


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
  •