What this does NOT do
I'm not trying to show the best way to layout a page or even make it look pretty. The css is basic and the values are chosen mostly to make clear the difference between one element and another. Even the html is simple, with no forms or anything else that could be interactive. They can be incorporated, but I wanted to keep this demostration simple.
What this DOES
First separation method
The first method reads a text file directly into an array. Since my text file has 3 lines, I choose between them and place the results in the array I'll be using to insert contents into the html to be sent to the browser.
Second separation method
This method prepares for the insertion of an entire file into the html by reading a file as text instead of an array.
Third method
This method uses an array or a variable to hold text/html. While it can be useful, it also provides the least separation (and is least desirable) since you're basically wrapping a chunk of html inside quotes in your php code.
You may have noticed that I added the css at the end, but it's one of the first items to be replaced in the example.html file. That's fine because I've kept the $replace array and the $with array in sync: Item number N in $replace is replaced with item number N in $with by str_replace().
So which is best, and are there others?
There are probably other ways, but these are easy to do and they're easy to manage. The best one is the one that works best for you and what you're doing. You might use any combination of them.
Attached File(s)
-
titles.txt (69bytes)
Number of downloads: 1362 -
Archive.zip (3.34K)
Number of downloads: 2409







MultiQuote



|