Jump to content

constants not working...


The Little Guy

Recommended Posts

I would like to get the directory the current file is in, but all I am getting is nothing...

 

var $dir = __dir__; // this just display __dir__ on the screen
// OR
var $dir = dirname(__file__); // this displays an error message: Parse error: syntax error, unexpected '(', expecting ',' or ';'

 

why are neither of these methods working?

Link to comment
https://forums.phpfreaks.com/topic/178566-constants-not-working/
Share on other sites

If your saying it is because I have them lowercase...

 

These special constants are case-insensitive

 

I found the reason __dir__ doesn't work, its because my php version is 5.2 and it was add 5.3

 

var $dir = dirname(__file__);

 

doesn't work because I am using it as a property, and I don't believe you can use functions when registering a property. Am I wrong about that?

If your saying it is because I have them lowercase...

 

These special constants are case-insensitive

 

Oh... good catch ;)

 

I found the reason __dir__ doesn't work, its because my php version is 5.2 and it was add 5.3

 

var $dir = dirname(__file__);

 

doesn't work because I am using it as a property, and I don't believe you can use functions when registering a property. Am I wrong about that?

 

Yeah. You need to do this assignment in constructor.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.