Error after hosting site

0

I have a problem and I do not know how to solve it. I and my college colleagues have created a site in PHP in clear localhost, when we host it 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   online 19

     

Notice: Use of undefined constant DIR - assumed ' DIR ' in   /home/storage/2/3e/eb/noticiasdasgerais/public_html/yteste/loader.php   online 19

     

Notice: Use of undefined constant DIR - assumed ' DIR ' in   /home/storage/2/3e/eb/noticiasdasgerais/public_html/yteste/loader.php   online 19

     

Notice: Use of undefined constant DIR - assumed ' DIR ' in   /home/storage/2/3e/eb/noticiasdasgerais/public_html/yteste/loader.php   online 19

Could someone give me a hand? We need to deliver this work this week.

Here is the code snippet of 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;
}
    
asked by anonymous 22.05.2017 / 15:18

1 answer

1

This constant __DIR__ exists only from version 5.3.0 of PHP.

Maybe the error is because localhost has this version, or higher, installed, but the final hosting does not.

EDITED:

If you do not know how to upgrade the final hosting version, do as Otto suggested and use dirname(__FILE__) instead of __DIR__ .

    
22.05.2017 / 15:58