0

The following is the direcory Structure of my application.



-/home/user 
| -/app
|  | -/class
|  |  |  -/proc
|  |  |   | -public_login.php
|  |  |   | -public_notice.php
|  |  |   | -public_reset.php
|  |  | -constants.php
|  |  | -utils.php
|  |  | -....
|  |  | -....
|  | -public_index.php
|  | -public_admin.php
| -public_html
  | -project_name
  | | -proc
  | | | - login.php
..........

Now in /public_html/proc/login.php I am including /app/class/proc/public_login.php using the following:

require_once('../../../app/class/proc/public_login.php');

Now inside the public_login.php there is requirement of app/class/utils.php so I added the following in the public_login.php.

require_once '../utils.php';

But I am getting 404 Error on this.

utils.php PATH

/home/user/app/class/utils.php

public_login.php path

/home/user/app/class/proc/public_login.php

Kindly help me solve this.

Regards
Genocide_Hoax

Genocide_Hoax
  • 843
  • 2
  • 18
  • 42

1 Answers1

2

Realtive path is configured from the initial file doing the include/requiring so in this case ../utils.php would evaluate to:

/home/user/public_html/project_name/utils.php

You can use the __DIR__ constant to get the path to the directory of the current file so from public_login.php you would do:

require_once __DIR__ . '/../utils.php';
prodigitalson
  • 60,050
  • 10
  • 100
  • 114
  • Thanks a lot. That worked. Is there any way to call a file in app/class/proc from public_html/ideal/js/? I am using a AJAX jason here. so is there any way to call the above? Currently I had to make a copy of the proc directory inside the public_html which I don't want to do. – Genocide_Hoax Apr 22 '13 at 18:11