_FILE_ & _LINE_ constant do not dispaly

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

<?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

They are surrounded by 2 underscores like so:


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.

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

FILE & LINE constant do not dispaly

The clue to the error was in your thread title :wink: 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 …

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.

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 :slight_smile:

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