Someone
Someone

Reputation: 10575

How to include a PHP Class file from the above folder

I am trying to include the File from the above folder . Iam here (www/pf/htdocs/ap) . I want to include a php file from the above www it is dev/libraray/hp.php

i am doing it in this way include_once ('../../../../dev/libraray/hp.php') but could not do it How could i do it

Upvotes: 0

Views: 287

Answers (3)

Wyck
Wyck

Reputation: 2023

You should use something like $_SERVER['DOCUMENT_ROOT'] in case you change the locations and folders or define a base path like define('BASE_URL', dirname($_SERVER["file_name"]));

Upvotes: 0

David Bélanger
David Bélanger

Reputation: 7438

Use the actual server directory path.

ex. include('/home/username/include.php');

Upvotes: 0

Tomasz Kowalczyk
Tomasz Kowalczyk

Reputation: 10467

  1. Be sure that target path is readable by PHP interpreter (can be read by user running it).
  2. If so, play with the "../" path, adding or substracting it from the include() string. for this one, removing it once should fix the problem, because you need to go 3 levels down:

include_once ('../../../dev/libraray/hp.php')

Upvotes: 2

Related Questions