SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru
    Join Date
    Oct 2010
    Location
    Portland, Or
    Posts
    727
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    _FILE_ & _LINE_ constant do not dispaly

    Am learning php and working my way trough a book & youtube tutorials.
    tried this

    PHP Code:
    <?php
    echo "<br>This file is "._FILE_;
    echo 
    "<br>This is line number "._LINE_;
    echo 
    "<br>I am using ".PHP_VERSION;
    echo 
    "<br>This test is being run on ".PHP_OS;
    ?>
    It should work according to the book and a google search, but this is what I get.

    Notice: Use of undefined constant _FILE_ - assumed '_FILE_' in C:\xampp\htdocs\phpBookMySql\index.php on line 4

    "This file is _FILE_
    Notice: Use of undefined constant _LINE_ - assumed '_LINE_' in C:\xampp\htdocs\phpBookMySql\index.php on line 5
    This is line number _LINE_
    I am using 5.4.4
    This test is being run on WINNT "

    why is _FILE_ & _LINE_ not showing up?
    thx
    D

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    They are surrounded by 2 underscores like so:

    PHP Code:
    echo "<br>This file is ".__FILE__
    echo 
    "<br>This is line number "__LINE__ 
    echo 
    "<br>I am using ".PHP_VERSION
    echo 
    "<br>This test is being run on ".PHP_OS
    You had singles _FILE_ etc.

  3. #3
    SitePoint Guru
    Join Date
    Oct 2010
    Location
    Portland, Or
    Posts
    727
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Exclamation

    oh for the love of...
    Thank you. wish they had mentioned that bit in book
    visually, didn't notice the two spaces.
    thx
    D

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    _FILE_ & _LINE_ constant do not dispaly
    The clue to the error was in your thread title Don't worry, we probably all fell for it. I was left scratching my head for a minute when I copied your text and got the same warnings as you ...

  5. #5
    SitePoint Guru
    Join Date
    Oct 2010
    Location
    Portland, Or
    Posts
    727
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Thx Cups!
    Nothing like trying to learn programming to remind you that booby traps and not just the devil is in the details and punctuation.

  6. #6
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Yeah, the general rule is, if it does not work and you have stared at it long enough and STILL cannot work it out, delete it and type it out again.

    This does not fix everything (I wish it did) but it does seem to fix some things.

    Sometimes your brain tells you what you want to see - you have to be aware of this shortcoming when starting out.

    I found this affliction does slowly recede as you spend more time developing and you learn other tricks in order to develop incrementally and code more defensively (using a good IDE will help here too), but when all else fails I will resort to this "just type it again, dummy" especially when tired or during bouts of AFD (alcohol fuelled development - blimey, cannot find that defined on t'internet, must have been a joke between a couple of us ....).

    Good luck with things

    (off to watch SB #47 and drink beer! Go Niners!)


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
  •