• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Including the same content on all pages (perhaps PHP?)

Puyo

n00b
Joined
Aug 11, 2006
Messages
47
Hello,

I am coding a site, but it's been so long that I've totally forgotten how to do PHP includes.

I am starting an anime review site so on all pages I want a "Recent Reviews" box next to my menu. Obviously, it would be quite time-consuming to have to edit every single freakin' page when I want to update the Recent Reviews box.

Can anyone refresh my memory on how to do PHP includes? I've looked at tutorials but they all assume I know the basics of PHP. Treat me as if I am a complete idiot (I am).
 
Okay. :cool:

What else do I need to do? Do all my pages need to end in .php? Does the "recentreviews.htm" page need anything special?
 
The page with the include needs to have a .php extension. The html file you are including needs only be HTML, no head content, no meta tags, simply the block of HTML you want included on the page in that specific location.
 
Also, if your include files are inside a sub-directory or outside your root folder, make sure the "include_path" directive in PHP.ini is pointing to it.
 
<?php

include('recentreviews.htm');

?>


I wouldn't use include to read html files.

just

echo get_file_contents('recentreviews.htm');

or simular to that (I usually just tab-complete functions in Zend, don't know them by heart)

this way php won't even try to parse the html file, thereby speeding your website up a lil' bit, and the chance of somebody putting php code in there beeing drastically reduced
 
I believe it's file_get_contents() but I couldn't swear to it... haven't used it in a while...
 
Back
Top