Reputation: 121
I need some help in linking a file in php.
Here is what I am looking for:
I have two files process.php
and index.php
, both placed in different directories.
This is the full path to process.php
file:
/home/happy92a/public_html/ggytg45ffs43456/wp/wp-content/themes/Funizm/loginsystem/process.php
I want to require_once index.php
within the process.php
file, How can I require it, here is the full path of index.php:
/home/happy92a/public_html/ggytg45ffs43456/wp/wp-content/plugins/plugged/index.php
I have already tried:
dirname(__FILE__)
but it gives the path to the current file (process.php
) not the (index.php
) which I want to include within process.php file.
I have also tried it with $_SERVER['DOCUMENT_ROOT']
but still it does not work also I have read it is bad practice to use server variable.
Upvotes: 0
Views: 86
Reputation: 191
Use DOCUMENT_ROOT:
require_once($_SERVER['DOCUMENT_ROOT'] . '/ggytg45ffs43456/wp/wp-content/plugins/plugged/index.php');
Upvotes: 0
Reputation: 13525
i am assuming your DOCUMENT_ROOT is at /home/happy92a/public_html/
if so using that as a base to build an absolute path by doing the following.
require_once ($_SERVER['DOCUMENT_ROOT'] . "/ggytg45ffs43456/wp/wp-content/plugins/plugged/index.php");
I read that you do not wish to use DOCUMENT_ROOT. you can then establish a constant for your wordpress installation called WP_DIR
define('WP_DIR', '/home/happy92a/public_html/ggytg45ffs43456/wp/');
require_once (WP_DIR . "wp-content/plugins/plugged/index.php");
Upvotes: 2
Reputation: 33993
try
require_once('./ggytg45ffs43456/wp/wp-content/plugins/plugged/index.php');
Upvotes: -1