include_once, relative path in php

前端 未结 5 765
-上瘾入骨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:51

    For the beginners this will help to understand. Use simply the following based on your relative path:

    //include file directly from parent directory:
    include_once(dirname(__FILE__) . '/../connect.php');
    

    OR

    //include file from parent's child directory:
    include_once(dirname(__FILE__) . '/../StoredProcedure/connect.php');
    

    OR

    //include file from own child directory:
    include_once('StoredProcedure/connect.php');
    

    OR

    //include sibling files from same directory:
    include_once('connect.php');
    

提交回复
热议问题