RE: [PHP] mixing HTML and PHP code

From: Date: Fri, 12 Jan 2001 00:27:59 +0000
Subject: RE: [PHP] mixing HTML and PHP code
Groups: php.general 
Request: Send a blank email to php-general+get-34168@lists.php.net to get a copy of this message
> > echo "<input type='text' name='hello' size='20' > > value='$value'>"; > > that isn't html anymore, though. > > even though IE and NS may be forgiving, <input type='text' > isn't valid. > > " it is. Er, actually ... you can use any quotes you like, you just have to be consistent and remember to close the one you open. > > Actually, it makes it less useable for me. > > how? It's harder to spot the code when the <?= shortcut is used. > and what about your html production people, who needs to make > changes to it? We've all agreed on this standard. Doesn't mean it's *the* standard (any more than yours is ;)), but the fact remains that it works for us. It also doesn't stop us going on about why we chose to do it in that way. :) > > I assemble *all* the page content into a single string variable, > > and echo it out as the last thing the script does. This way I'm > > free to play with HTTP headers right up to that time. > > agh! > > well, ok - but I suggest that you use functions instead, and call your html > printing functions at the end of your script. or better, build simple > components, and glue them together to make an application > that consists of files that do logical operations, and files that > contain markup. Er, yeah ... thats what I just said we do :) This *does* scale quite nicely. We're running 4 or 5 completely different sites now off the same function codebase. > But I certainly can't integrate code into a production > process that looks like this: > [snip - pukeworthy ;)] > get one of your friends that knows html but not PHP to look > at the above, then this: [snip - also pukeworthy ;)] > and see what they have to say. Well ... it also depends on your team members. Our team has a distinct programming bent to it (and then there's me, who hates programming but loved PHP scripting, go figure! :)). A team with more of a HTML edge will probably prefer your way. For an availability check on www.inww.com, we tend to do something like this: <? $check = checkgTLD($domainname); if ($check[result] == "success") { if ($check[availability] == "available") { $result = "<<some big complicated HTML chunk for available domains>>"; } else { $result = "<<some big complicated HTML chunk for UNavailable domains>>"; } } else { $result = "<<some big complicated HTML for when everything goes pearshaped>>"; } // At this point we pull in the sidebar content for the page, too, then: $output = generatePageLayout($result); include("$DocRoot/subpagestart.php3"); echo $output; include("$DocRoot/subpagestop.php3"); ?> There's advantages and disadvantages to both our ways, really. It's not worth an in-depth discussion because I think I've just sent everyone on the list to sleep as-is. But our way works for us just as well as your way works for you :) Jason -- Jason Murray jasonm@melbourneit.com.au Web Design Team, Melbourne IT Fetch the comfy chair!

« previous php.general (#34168) next »