Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   PHP (http://www.programmingforums.org/forum29.html)
-   -   pages content (http://www.programmingforums.org/showthread.php?t=8214)

Nimwa2 Feb 1st, 2006 11:18 AM

pages content
 
lets say i have 10 pages on html and it sucks to sit and edit everything on each single page isnt there some php that i can add where if i make changes in the index file it will make the same change in all the pages?

DaWei Feb 1st, 2006 11:28 AM

If you generate the similar parts with PHP, or include the similar parts, you only have to change one piece of the source. You might also investigate templates. You probably need to investigate or review the place of PHP as server-side code. Your problem, of course, isn't new; it is old and well-addressed.

Ooble Feb 1st, 2006 12:24 PM

If you don't know PHP, the official documentation is a very good starting point:

http://www.php.net/

Plate Feb 1st, 2006 8:37 PM

Specifically, when you look into the PHP documentation, look at the "include" function. This function is will parse a PHP file where you can singly place some data. I usually use this function for larger text areas in templated websites.

If you have many small bits of data you might want look into the superglobal array "$GLOBALS" to reference, on different pages, globals values in a single file. To use this though you'll need globals enabled in the php.ini file and it can be a security risk.

The next, more complex, method would be to use a database such as MySQL as a single point to store data.

DaWei Feb 1st, 2006 8:43 PM

A MySQL database seems like a poor way to store boilerplate, although it would be functional. Unless you wanted to vary it with some type of query, a flat file would be better (and could be included).

Silvanus Feb 1st, 2006 9:13 PM

Actually you don't need PHP for this- SSI should do the job.

Infinite Recursion Feb 1st, 2006 9:48 PM

The include method of PHP is what you want.

For instance:

[PHP]
<?php

include ("header.php");
include ("main.html");
?>
[/PHP]


All times are GMT -5. The time now is 7:43 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC