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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.