common webpage content
Hi,
I'm new to php.I had to include common content to a lot of webpages in my website like menubar etc. and i was told i could load them dynamically from a single file using php.Can someone help me with this?
AutoC
Junior Poster in Training
74 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
You can either use require_once to include another file, or if you want something more fancy, you could use templates (smarty for example).
pritaeas
Posting Expert
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
As a beginner, I suggest you use the function "require" like this:
(require "includes/common.php");
Yes, require has a different syntax, to avoid future problems, always surround the hole statement with parenthesis.
What future problems are you talking about ? Could you explain this a bit better ?
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
I haven't seen anyone using require or include inside a brace like this though.
<?php
(include "db.php");
(require "db.php");
?>
But the point to be noted is, include and requiredo return a value on successful inclusion. That return value is OK . Strange. I didn't know that :) I wonder what would be the return value on failure.
Also, include and require are not functions. They are language constructs. Hmm! Not bad to learn few new things @ 2-30 am ? Eh ? ;)
nav33n
Purple hazed!
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356