Thursday, 19 September 2013

Can I use dirname(__FILE__) as a part of a string?

Can I use dirname(__FILE__) as a part of a string?

I use dirname(__FILE__) in includes in php scripts but the other day I
included it as part of a string and it caused an error. Any ideas?
THe line was
private $errorfile = dirname(__FILE__).'/../../../error_logs/error.log';
or
private $errorfile = '/../../../error_logs/error.log';
error_log($message,3, dirname(__FILE__).$this->errorfile);
and it caused an error such as
PHP Parse error: syntax error, unexpected '(', expecting ',' or ';' in
/home2/futsalti/public_html/_futsal-time-v4.9/public/scripts/php/databaseClass.php
PHP Parse error: syntax error, unexpected ';' in
/home2/futsalti/public_html/_futsal-time-v4.9/public/scripts/php/databaseClass.php
EDIT:
Ok, just came to me... Maybe the question should be can I use
dirname(__FILE__) inside a class?

No comments:

Post a Comment