Re: mixing HTML and PHP code

From: Date: Thu, 11 Jan 2001 23:26:47 +0000
Subject: Re: mixing HTML and PHP code
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-34203@lists.php.net to get a copy of this message
On Thu, 11 Jan 2001, Alex Black wrote: > like this: > > echo "<html>"; > echo "<head>"; > echo "<title>$title</title>"; > echo "<link rel='stylesheet' type='text/css' > href='resources/css/$css.css'>"; > echo "<script src='/resources/js/base_lib.js' > language='javascript'></script>"; > echo "</head>"; > echo "<body bgcolor='#EEEEEE' text='#000000' > link='#003366' alink='#CCCCCC' But why would you EVER write it like that. if ($time_to_write_the_web_page) { // write the web page. echo " <html> <head> <title>$title</title> "; insert_css_js_here(); echo " </head> <body bgcolor=\"#EEEEEE\"> "; // yada yada } works fine and is pretty easy to read. And my friend who was an html expert but not a php expert had no problem reading my code. Now this is NOT saying that extraction of markup from logic isn't a good thing. I DO separate logic from markup. However, the beauty of PHP is that markup doesn't need to be separated. And for many projects, its probably overkill. -burk -- burk@pobox.com

« previous php.general (#34203) next »