![]() |
| ||
| 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? |
| ||
| Re: common webpage content You can either use require_once to include another file, or if you want something more fancy, you could use templates (smarty for example). |
| ||
| Re: common webpage content 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. |
| ||
| Re: common webpage content Quote:
|
| ||
| Re: common webpage content This works fine: if( (require "sql.php") && 1) Whereas this produces a fatal error: if( require("sql.php") && 1)the error:Quote:
----------------------- From the PHP manual for include() (same rules apply for require): Because include() is a special language construct, parentheses are not needed around its argument. Take care when comparing return value. http://www.php.net/manual/en/function.include.php |
| ||
| Re: common webpage content I haven't seen anyone using require or include inside a brace like this though. <?phpBut the point to be noted is, include and require do 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 ? ;) |
| ||
| Re: common webpage content Yes, I was wrong, these are language constructs. I wrote "&& 1", the "1" could any arbitrary PHP expression... |
| All times are GMT -4. The time now is 11:41 am. |
Forum system based on vBulletin Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
©2003 - 2010 DaniWeb® LLC