|
Posted by Kenneth Downs on 01/10/07 00:25
Michael wrote:
> Hi,
>
> A quick and most likely simply question about which is generally better
> programming with PHP. Is it more proper to break out of PHP code to write
> HTML, or is it ok rto do it within print() statements? Such as...
I find code easier to read if it is almost entirely PHP or almost entirely
HTML. Therefore, large blocks of static HTML with little or no dynamic
content will use html:
// php code goes here....
?>
<h1>Welcome to the Wizard!</h1>
<p>Welcome, <?=$user_id?>, to our wizard, we hope
that you will find it easy to use, and all
of that nonsense.
<?php
// ...more php code
However, if I am stringing together text that is more variables than static,
it tends to look better and be easier to read if it is a list of PHP
commands:
$row=SQL_OneRow("Select * from customers...")
echo "Hello ".$row['user_id'];
echo ", I see you are from ".$row['city'];
echo ", and that you have ".$row['eyecolor']." eyes";
>
> SCRENARIO A)
> <?php
> ...code...
> ?>
> <img src="<?=$imgsrc?>">
> <?php
> ...more code...
> ?>
>
> SCENARIO B)
> <?php
> ...code...
> print("<img src=\"".$imgsrc."\">");
> ...more code...
> ?>
>
> Thanks,
> Michael
--
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth@(Sec)ure(Dat)a(.com)
Navigation:
[Reply to this message]
|