-
Website
http://elbertf.com/ -
Original page
http://ElbertF.com/index.php/2009/03/tips-for-writing-compact-php-code/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
MrJoax
2 comments · 1 points
-
robert vayner
1 comment · 1 points
-
Wimsito
3 comments · 1 points
-
CoenJacobs
2 comments · 1 points
-
fakeout
1 comment · 1 points
-
-
Popular Threads
$foo =
$bar = false
$foobar = true;
But thanks for the tips, because they definitely are usefull!
Great article Elbert.
Though I would like to point out that certain ways of coding are actually faster/more efficient, for instance in example 8 using the code this way..
$variable[] = "value1";
$variable[] = "value2";
is slower than doing...
$variable ( 'value1', 'value2' );
Also one tip for writing more readable code is by using switch statements, long if else statements can get messy, use a switch to make it easy and readable
if (condition)
{
do something;
}
else
{
do something else;
}
is 8 lines, while
if (condition) {
do something;
} else {
do somerhing else;
}
is only 5 lines and more readable to me