0
I have a problem and I don’t know how to solve it. My college colleagues and I created a PHP in clear localhost, when we host it displays the following error:
Notice: Use of Undefined Constant DIR - assumed 'DIR' in /home/Storage/2/3e/Eb/noticiasdasgerais/public_html/yteste/Loader.php on line 19
Notice: Use of Undefined Constant DIR - assumed 'DIR' in /home/Storage/2/3e/Eb/noticiasdasgerais/public_html/yteste/Loader.php on line 19
Notice: Use of Undefined Constant DIR - assumed 'DIR' in /home/Storage/2/3e/Eb/noticiasdasgerais/public_html/yteste/Loader.php on line 19
Notice: Use of Undefined Constant DIR - assumed 'DIR' in /home/Storage/2/3e/Eb/noticiasdasgerais/public_html/yteste/Loader.php on line 19
Could someone give me a hand? We need to deliver this paper this week.
Here is the code snippet from line 19
function __autoload($className) {
$r = new RouterController;
//procura primeiro na raiz da app
$classpath = array('Lib', 'helpers', 'Model', 'Controller');
$classFile = $className . ".php";
$loaded = false;
$mod_path = __DIR__ . "/$path" . "/$classFile";
if (is_readable("$mod_path")) {
require "$mod_path";
$loaded = true;
break;
//return false;
}
if (is_readable("$path$classFile")) {
require "$path$classFile";
$loaded = true;
break;
//return false;
}
}
$reserved = array('finfo');
if ($loaded == false && !in_array("$className", $reserved)) {
$baseurl = $r->base();
//@Router::redirect("$baseurl/404.php?return=$baseurl");
exit;
}
You haven’t defined the constant
DIR
, see error message: Use of Undefined Constant DIR.– Woss
It wouldn’t be a mistake, like the Notice message itself, but you could use the dirname(FILE) instead of DIR
– Otto
you have to change the localhost variables to the ones in the serverhost or check the dophp version to change dir to dirname(file) as the colleague mentioned for example
– flourigh
Now appeared these: Notice: Use of Undefined Constant FILE - assumed 'FILE' in /home/Storage/2/3e/Eb/newssgerals/public_html/yteste/Loader.php on line 19 Parse error: syntax error, Unexpected T_OBJECT_OPERATOR in /home/Storage/2/3e/Eb/newssgerais/public_html/yteste/Controller/index.php on line 7
– Márvin Edge
What is that
DIR
does? Did you define it? What is the purpose of it and how is it used? Please [Edit] the question and add these details.– Woss
Edit your question with the code snippet for "/home/Storage/2/3e/Eb/noticiasdasgerais/public_html/yteste/Loader.php on line 19"
– Rayann Nayran
@Márvinedge I formatted your code there in the question, but realize she’s wrong. The function is finished and there is still code after which I imagine it should go inside the function. Confirm that this is how it is in your code.
– Woss
your $baseurl is set to?
– flourigh