include_once, relative path in php

前端 未结 5 756
-上瘾入骨i
-上瘾入骨i 2021-01-18 02:36

I have 3 files: home, failed_attempt, login.

The file home and failed_attempt all refer to login file.

The annoying thing is that they throw a mistake saying

5条回答
  •  囚心锁ツ
    2021-01-18 02:58

    The other guys have answered your question correctly, however I thought I'd contribute something else: autoloaders.

    Autoloaders allow you to define a function that will automatically include certain files, when you attempt to use a class.

    The documentation is here and can explain it better than I can: http://php.net/manual/en/language.oop5.autoload.php

    Would really recommend using them, will save you time and is better practice.

提交回复
热议问题