search

Home  >  Q&A  >  body text

userAutoLoad method cannot use MODULE constants

require './application/home/model/'.$className.'.php';
require './application/home/controller/'.$className.'.php';

The teacher wrote the home module directly in the code. If I loaded the custom class from another module, it would cause an error. So I used the MODULE constant declared by the getRequestParams method to replace the module, but the program reported an error, prompting that the MODULE constant was not declared. , is it because the getRequestParams method is a private attribute. So what should I do most correctly? Thank you


碎天碎天2096 days ago992

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2019-02-22 16:42:58

    You have two options:

    1. Create a path constant: APP_PATH = __DIR__;

    2. Or in the directory you want to load Add: __DIR__ before the file, referencing the absolute path address of the current script as the starting path


    In this way, an absolute path to the imported file will be created.

    reply
    0
  • Cancelreply