Connecting Tech Pros Worldwide Help | Site Map

Code Conventions and preferences

  #1  
Old July 17th, 2005, 03:15 PM
julian maisano
Guest
 
Posts: n/a
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, 03:15 PM
Shelly
Guest
 
Posts: n/a

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, 03:15 PM
R. Rajesh Jeba Anbiah
Guest
 
Posts: n/a

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, 03:16 PM
no@emails.thx
Guest
 
Posts: n/a

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, 04:45 PM
Chung Leong
Guest
 
Posts: n/a

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, 07:56 AM
Norman Peelman
Guest
 
Posts: n/a

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


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable naming conventions. pereges answers 36 August 12th, 2008 03:15 PM
C# naming conventions (is m_varName used?) Zytan answers 47 March 2nd, 2007 08:45 PM
Boolean Naming Conventions news.microsoft.com answers 38 November 16th, 2005 08:19 AM
How to enforce coding style conventions Ron Burd answers 29 November 16th, 2005 04:18 AM