You are here: Coding style... « All PHP « IT news, forums, messages
Coding style...

Posted by Curtis on 01/02/06 10:20

Occasionally I encounter this style of coding, where the
coder is apparently religiously opposed to outputting HTML
with PHP. The result is very difficult to read:

<?php
global $user;
if ($user->uid) {?> <li><a href="logout" title="">Log
Out</a></li>
<?php } else {?> <li><a href="user/login" title="">Log
In</a></li>
<?php }?>

Ten characters in order to type that closing brace? Wow.

What's the thinking behind this style, and what's wrong with
the following?

<?php
global $user;
if ($user->uid)
{
print '<li><a href="logout" title="">Log Out</a></li>';
}
else


print '<li><a href="user/login" title="">Log
In</a></li>';
}
?>

.... assuming one wanted to keep the braces, and didn't want
to escape quotes.

While I'm on the subject, I note that a lot of PHP coders do
the opening braces like so:

<?php
if ($something) {
do this();
} else

dothat();
}
?>


I don't find this as readable/maintainable as lining up
opening and closing braces the same way I would line up

begin
begin
end
end

in Pascal--especially when things get nested three or four
levels deep.

--

Curtis

Visit We the Thinking
www.wethethinking.com
An online magazine/forum
devoted to philosophical
thought.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация