View Full Version : Dumb Include (Vs. Smart Include)
Is there anyone else that thinks an HTML language like PHP that cannot include other HTML/PHP documents is a little debilitating? It seems the Include statement results in a document with duplicate <html>, <title>, etc. elements.
Since PHP is, afterall, an html scripting language, allowing html errors to be introduced this way seems to be a design error.
It would be really nice if PHP could strip these elements before including them so that code could be re-useable. Having to maintain separate html and template files makes converting from CGI rather mute (for me anyway).
Perhaps I have missed another statement that will allow this. If so, please set me straight!
Rich
Justin
05-11-1999, 12:20 AM
Hey, Rich - I think you're missing the true power of PHP :)
The include() function does exactly that - it simply adds the contents of the file to be included at the point the include statement was in.
You can include other php files as well, even with php code in them, just so they have the proper <? and ?> tags.
What you may want to look into is doing what millions of sites do already with SSI's. Create a common header and footer file, and each page simply includes the header and footer at the top and bottom of the page.
My site, www.HostFacts.com (http://www.HostFacts.com), does just that - every single page uses it, and I even have a function in the footer to properly close the MySQL connection if one is in fact open :)[nbsp][nbsp]For pages that need to connect to the database, I also include another file containing the variables for the database as well as the command to connect - to avoid having to repeat them :)
I love PHP and will never EVER design another site without it :D
I hope this helps - basically it will include whatever is in the file. Oh, if you really needed to, you could fopen() a file (either local or remote) and use regular expressions to remove the <html><head><etc> tags. PHP's regex is based on the POSIX regular expressions, and is not nearly as powerful as Perl's, but it works well and would be simple for that purpose :)
------------------
Justin Nelson
FutureQuest Support
jonas
06-09-1999, 04:47 AM
Justin, with PHP 3.0.9 Regular expression is "Perl compitable" :-)
Terra
06-09-1999, 03:01 PM
I will probably be rolling a new Apache1.3.6/PHP3.0.9 combination this weekend for the primaries...
I will also be implementing a way to upload with the PHP3 Safe Mode being on...[nbsp][nbsp]I will be tying this capability to an internal suEXEC'd perl script that will handle the final moves/transfer...[nbsp][nbsp]Will need to test it with the PHP3.0.9 to make sure they mods will carry over...
--
Terra
--so much to do, so many delays--
FutureQuest
SneakyDave
06-09-1999, 03:17 PM
Woohoo!
Regarding SAFE MODE, if I understand correctly, this suEXEC solution will just resolve the UPLOAD issues with SAFE MODE, correct?
pdstein
06-09-1999, 03:44 PM
Hey Terra,
Lookin' forward to using that file upload![nbsp][nbsp]Thanks for all the work you're putting into it.[nbsp][nbsp]I'll keep my fingers crossed and look for the "it's ready" post this weekend. :)
- Paul
Terra
06-10-1999, 02:22 AM
Blah, *grumble* - throw things - grrrrrrrr
I'm trying to build the new ApacheSSL/OpenSSL/mod_SSL/PHP3 server and it would figure that the 'pcre' "Perl Compatible Regular Expressions" is throwing fits on me...
This beast is probably one of the **most difficult** daemons that we have to build and the most wanted feature is throwing tons of monkey wrenchs... (spent the last 13 hours configuring, compiling, testing, and plugging all the pieces together)
*sigh*
--
--No Terra, the round peg does NOT go in the square hole -- "Oh yeah, wanna see my sledgehammer??"--
FutureQuest
Dean B
06-10-1999, 09:59 AM
Actually, the round peg will fit into the square hole, just the square peg won't fit into the round hole.
Hehehehe...... :)
Terra
06-11-1999, 01:45 AM
Oh Man, I don't **even** want to discuss getting the new ApacheSSL compiled with all the latest stuff...
In the end - creative measures reigned by using a slick combination of APACI Apache/OpenSSL/mod_ssl/mm configuration and compilation, and then force feeding PHP3 into Apache via the apxs mechanism...[nbsp][nbsp]Eeeeeesh!
Well 28 (solid) hours later of invested time I've got the first production build into place, and the xIP Apache primaries are next...[nbsp][nbsp]I figured if I could figure out how to snap all the pieces of the beast above, then the regular primaries should be a snap...[nbsp][nbsp](hoping/wishing/praying)
To avoid rambling, the new ApacheSSL is PHP_3.0.9+PCRE driven and supports the new DSA (Diffie/Helman) and older RSA keys - it should also handle the Verisign PEM certs without a problem as well...
--
Terra
--My round pegs were always larger than the square holes--
FutureQuest
SneakyDave
06-11-1999, 10:13 AM
Uh... yeah, sounds good Terra, would you like a left handed monkeywrench?
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.