Bashir ahmad
Bashir ahmad

Reputation: 241

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.

I always getting this error

This is the tree of the folders

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

Upvotes: 0

Views: 1111

Answers (3)

Prashant
Prashant

Reputation: 248

Include following lines of code in your file

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

Upvotes: 2

Thomas Rbt
Thomas Rbt

Reputation: 1540

The folder where the file is, and the file master.php are in the same folder :

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

Upvotes: 1

Palethorn
Palethorn

Reputation: 379

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.

Upvotes: 1

Related Questions