We help IT Professionals succeed at work.
Get Started

php issue when using the include function

NBSHOMES
NBSHOMES asked
on
142 Views
Last Modified: 2015-04-11
I'm currently loading an include file "includes/omniPro/profile-info.php" into a php page "about/index.php". This file contains many strings, variables and alike. I have another file "includes/omniPro/head-elements.php" that I would like to include on this same "about/index.php" page with the site menu and a few other things that directly relates to this "profile-info.php" file.

The problem is that, this only works when I place the code directly on the "about/index.php" page. When I try to do the same by including the file, it doesn't work. I already checked if it was something related to file path and it's not. Some elements of the include file are loaded but not the piece of code I need.

The file structure is as follow:
about/index.php (this is the webpage I'm loading the files into)
includes/omniPro/profile-info.php (This is the file containing many variables, strings and etc)
includes/omniPro/head-elements.php (This is the file containing the peace of code)

The Syntax:
<link rel="stylesheet" href="<?php echo 'http://' . $_SERVER['HTTP_HOST']; ?>/css/colors.php?color=<?php if($color {main} == '') { foreach ($page as $key => $item) if ($page[$key][4] == basename(__DIR__)) echo $page[$key][2];} else echo $color {main}; ?>" type="text/css" />

Open in new window


When included, the rendered HTML page shows:
<link rel="stylesheet" href="http://localhost:8888/css/colors.php?color=" type="text/css" />

Open in new window


This is the supposed rendered HTMLs - showing a color code:
<link rel="stylesheet" href="http://localhost:8888/css/colors.php?color=FCC444" type="text/css" />

Open in new window

This works just fine if I place this code directly on about/index.php.

I have attached the files for your review. So how can I solve this problem? Any help is very much appreciated. Thanks for the help.
profile-info.php
head-elements.php
index.php
Comment
Watch Question
Frontend Engineer and UX
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 7 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE