php includes

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
Grahamhart
Forum Commoner
Posts: 27
Joined: Wed Jun 11, 2008 6:05 am

php includes

Post by Grahamhart »

This question is somewhat theory based, I ask it here as I havent been able to find an answer elsewhere.

I have started using includes more in my php codes as a means to stop me having to repeat code needlessly but i have been noticing that some functionality has been getting lost when moving my code over to includes, I dont understand why this happens.

Issues that i have notices are things such as CSS functions such as filters for applying gradient fades and mouseover / mouseout ceasing to work once moved to an include. The code doesnt change and they work perfectly when put directly into the php files.

If anyone could shed some light on this for me, i would greatly appreciate it.
joel24
Forum Newbie
Posts: 10
Joined: Tue Feb 03, 2009 6:18 am

Re: php includes

Post by joel24 »

... does the rest of the css for the page work and just some elements cease to work?

is the css linked to the master PHP file location, and not the location of the included file itself??
if that makes sense...?
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Re: php includes

Post by mattpointblank »

Yep, you're probably losing the css files - remember that an included file takes on the location of the file it's included into, so links need to be relative to that. Also, it's possible existing css styles on the page including the file are overriding your initial ones.
Grahamhart
Forum Commoner
Posts: 27
Joined: Wed Jun 11, 2008 6:05 am

Re: php includes

Post by Grahamhart »

The rest of the css is working ok just some functionality, the paths in the include are as though they would be if routed form the hp file they are included in. The css is Linked to from the php file itself, i will post some examples here to attempt to better show what is occuring.

Example one, no exterior css effects this example except the STRONG elements which work when in the include.

<td height="20" width="107" id="td50" background="images/activetoptab.gif"><a href="home.html" onMouseOver="td50.background='images/overtoptab.gif'" onMouseOut="td50.background='images/activetoptab.gif'">&nbsp;<strong>Home</strong></a></td>

This is one of my menu tabs which stay constant. I took the entire table out of all of my pages and put it into an include and called that instead. The rollovers then ceased to work.

Example two, this one uses the external CSS file.

<div class="box" style="background: green; filter: progid:DXImageTransform.Microsoft.Alpha
(Opacity=100, FinishOpacity=20, Style=1, StartX=0, FinishX=0, StartY=100, FinishY=0)">Contents</div>


This code should create a gradient effect and when in the main php file operates as intended, when put into an include, i get a solid block of color. I attemted to move all of the code into the external CSS file and still found the same problem, one single block of color.

I hope this helps to clarify what i mean. Thank you for your comments so far.
Post Reply