简体   繁体   中英

php how to include file from an another folder

I want include file from another folder. i used different ways but nothing helped me out. One folder back solution and two folders back none gave me any positive respone.

我总是收到这个错误

这是文件夹的树

<?php
   include_once('./../models/config.php');
?>

在文件中包含以下代码行

<?php require_once('../models/config.php'); ?>

How about this:

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'config.php'

Your models directory is in same path as master.php. I recommend always using absolute paths for this kind of things.

该文件所在的文件夹与master.php文件位于同一文件夹中:

<?php include_once('models/config.php'); ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM