Jump to content

Include not working?


DarkxPunk

Recommended Posts

Hi there,

 

I am new to PHP, but have been playing with include for awhile. Today I can't get it to work the normal way I have always worked with it, here is my issue:

 

$contentHome = '../content/public/home.php';switch (true){case $currentSite == "www.domain.tdl" and $currentPage == "home.php":case $currentSite == "domain.tdl" and $currentPage == "home.php":include_once($contentHome);$welcome = $welcome;break;

 

This gives me an error saying the dir does not exist… Now doing a lot of searching I found this solution:

 

define('ROOT', __DIR__.'/');$contentHome = ROOT.'../content/public/home.php';switch (true){case $currentSite == "www.domain.tdl" and $currentPage == "home.php":case $currentSite == "domain.tdl" and $currentPage == "home.php":include_once($contentHome);$welcome = $welcome;break;

 

It works perfect using this code. I understand why, but what I don't understand is why the first example of code does not work!?

 

Thanks for any input.

Michael

 

Link to comment
Share on other sites

why are you using spoiler tags to show code? :huh:

 

You will notice I am using the proper code tags inside the spoiler tags… Now the reason…well I think it looks cleaner. Just me.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...