Connecting Tech Pros Worldwide Help | Site Map

Code Conventions and preferences

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 02:15 PM
julian maisano
Guest
 
Posts: n/a
Default Code Conventions and preferences

A kind of survey...

1) what do yo prefer?

a)
echo '<table border="1" width="100%" border="0" cellspacing="0">';
?>

or
b)
?>
</table>

I mean, html inside php block or outside?

regards - jm

  #2  
Old July 17th, 2005, 02:15 PM
Shelly
Guest
 
Posts: n/a
Default Re: Code Conventions and preferences

I prefer the first if it is surrounded by other php statements. I don't
like hopping in and out of php.

Shelly

"julian maisano" <julianmaisanoXYZ@gmail.com> wrote in message
news:dbcggi$602$1@domitilla.aioe.org...[color=blue]
>A kind of survey...
>
> 1) what do yo prefer?
>
> a)
> echo '<table border="1" width="100%" border="0" cellspacing="0">';
> ?>
>
> or
> b)
> ?>
> </table>
>
> I mean, html inside php block or outside?
>
> regards - jm[/color]


  #3  
Old July 17th, 2005, 02:15 PM
R. Rajesh Jeba Anbiah
Guest
 
Posts: n/a
Default Re: Code Conventions and preferences

julian maisano wrote:[color=blue]
> A kind of survey...
>
> 1) what do yo prefer?
>
> a)
> echo '<table border="1" width="100%" border="0" cellspacing="0">';
> ?>
>
> or
> b)
> ?>
> </table>
>
> I mean, html inside php block or outside?[/color]

Seriously against to (a). Not sure, what is (b). I embed html inside
PHP and vice versa. I use echo only to output data, but never to output
html. Mine is:

<div id="main">
<?php
if ($foo)
{
?>
<p>Condition is true</p>
<?php
}
?>
<table summary="<?php echo $foo->getValue('summary');?>">
<tr>
<td><?php echo $foo->getValue('foo1');?></td><td><?php echo
$foo->getValue('foo2');?></td>
</tr>
<tr>
<td><?php echo $foo->getValue('foo3');?></td><td><?php echo
$foo->getValue('foo4');?></td>
</tr>
</table>
</div>

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

  #4  
Old July 17th, 2005, 02:16 PM
no@emails.thx
Guest
 
Posts: n/a
Default Re: Code Conventions and preferences

On Sat, 16 Jul 2005 23:40:55 -0500, julian maisano
<julianmaisanoXYZ@gmail.com> wrote:[color=blue]
>A kind of survey...
>
>1) what do yo prefer?
>
>a)
>echo '<table border="1" width="100%" border="0" cellspacing="0">';
>?>
>
>or
>b)
>?>
></table>
>
>I mean, html inside php block or outside?[/color]

I'd say it is all down to which predominates ... some of my pages are
purely HTML so they need no PHP. Others might just need a small bit of
database-derived information or some constants or included blocks etc
so i have the HTML surrounding one or two small <?php ... ?> areas.
But if the page is basically all includes and logic or data-derived
areas then i'd start with a <?php and finish with ?> and then echo
the HTML inside.

Basically, I agree with one of the other posters - avoid jumping in
and out of PHP because it makes the code very hard to follow and debug
later. Also, it's as much as anything down to readability and
presenting an intuitive source-code - so think of the person following
on from you who has to maintain the site - or even yourself a year on.
Put in plenty of comments describing what the script should do over
all - and then in more detail before major sections describing perhaps
why you chose to do the code in such a way.

Chris
  #5  
Old July 18th, 2005, 03:45 PM
Chung Leong
Guest
 
Posts: n/a
Default Re: Code Conventions and preferences

Echoing HTML from PHP gets tricky when you have any embedded
Javascript. I usually break out of PHP when there's a large chunk of
HTML.

  #6  
Old July 21st, 2005, 06:56 AM
Norman Peelman
Guest
 
Posts: n/a
Default Re: Code Conventions and preferences


"Chung Leong" <chernyshevsky@hotmail.com> wrote in message
news:1121701181.036632.42660@g47g2000cwa.googlegro ups.com...[color=blue]
> Echoing HTML from PHP gets tricky when you have any embedded
> Javascript. I usually break out of PHP when there's a large chunk of
> HTML.
>[/color]

What happens then???

Norm
---
Avatar Hosting at www.easyavatar.com


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.