Require_once

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
YoussefSiblini
Forum Contributor
Posts: 206
Joined: Thu Jul 21, 2011 1:51 pm

Require_once

Post by YoussefSiblini »

Hi Guys,
I am having trouble here,
when I use this code

Code: Select all

<?php include "includes/header.php" ?>
every thing works fine:

But when I use the full url to that file like this

Code: Select all

<?php include "http://www.mydomain.com/includes/header.php" ?>
it doesn't work.


As I have a big website I need to use the full path.


Youssef
YoussefSiblini
Forum Contributor
Posts: 206
Joined: Thu Jul 21, 2011 1:51 pm

Re: Require_once

Post by YoussefSiblini »

Ignore this guys as I sorted it out, I used $_SERVER['DOCUMENT_ROOT'] :)
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Require_once

Post by social_experiment »

fyi
The Manual wrote: If "URL fopen wrappers" are enabled in PHP (which they are in the default configuration), you can specify the file to be included using a URL (via HTTP or other supported wrapper - see List of Supported Protocols/Wrappers for a list of protocols) instead of a local pathname.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
YoussefSiblini
Forum Contributor
Posts: 206
Joined: Thu Jul 21, 2011 1:51 pm

Re: Require_once

Post by YoussefSiblini »

Thank you,
I prefer $_SERVER['DOCUMENT_ROOT'] because it works in both local and live environment.

Youssef
Post Reply