Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > PHP magic constants not working

PHP magic constants not working
Thread Tools
Fresh-Faced Recruit
Join Date: Oct 2003
Location: Nebraska
Status: Offline
Reply With Quote
Jul 22, 2005, 08:32 PM
 
I am currently working with a server that seems not to support php constants like _FILE_ and _LINE_. How did they manage this? I can't find anything using phpinfo() that would tell me why they aren't working.

I have a class that uses a configuration file that must reside in the directory with the class not the file that includes the class. _FILE_ would have been useful. I can use dirname($_SERVER["SCRIPT_FILENAME")] but I would like to know how and why the magic constants aren't working.

[PHP]
$home = _FILE_;
echo(_FILE_);
[/PHP]

Simply doesn't work. Output is just
_FILE_
     
Grizzled Veteran
Join Date: Oct 2003
Status: Offline
Reply With Quote
Jul 22, 2005, 10:34 PM
 
That would probably be because there is no _FILE_ or _LINE_ or any other _XXX_ constant.

However, there is __FILE__, __LINE__, etc...

http://www.php.net/manual/en/languag...predefined.php

The only thing necessary for evil to flourish is for good men to do nothing
- Edmund Burke
     
Fresh-Faced Recruit
Join Date: Oct 2003
Location: Nebraska
Status: Offline
Reply With Quote
Jul 23, 2005, 10:07 AM
 

Two underscores. Ooops. Thanks for the tip. Don't know how I missed that.
     
Mac Elite
Join Date: Mar 2002
Location: Clogland
Status: Offline
Reply With Quote
Jul 23, 2005, 12:03 PM
 
Originally Posted by Hammer65

Don't know how I missed that.
I do, hiccups like that happen to me all the time, hours of ripping one's hair out "It must work, why doesn't it work?", hours of Googling, then eventually posting a thread here or elsewhere, only to find out that the solution was THAT SIMPLE.

Plus point is, you'll never make that mistake again.
     
Fresh-Faced Recruit
Join Date: Oct 2003
Location: Nebraska
Status: Offline
Reply With Quote
Jul 23, 2005, 02:31 PM
 
Okay for everybody that has ever done that let's all have one big Homer Simpson! Dohh!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:22 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2