iBlog random » code http://blog.zurka.us Just another WordPress weblog Tue, 28 May 2013 20:28:47 +0000 en-US hourly 1 http://wordpress.org/?v=3.6 Write less PHP code http://blog.zurka.us/write-less-php-code/ http://blog.zurka.us/write-less-php-code/#comments Fri, 17 Oct 2008 11:48:37 +0000 nasal http://blog.zurka.us/?p=609

I found a funny but working way to write less php and more html code..

Instead of writing:

<?php
	echo '< form action="" method="post">';
	echo '< input type="text" name="something">';
	echo '< /form>';
?>

We could write:

<?php { ?>
	< form action="" method="post">
	< input type="text" name="something">
	< /form>
<?php } ?>

Or maybe instead of this if – else method:

<?php
if ($something == $value) {
	echo '< div class="ok">The value is the same as $something< /div>';
} else {
	echo '< div class="ko">The value is NOT the same as $something< /div>';
}
?>

We could use:

<?php if ($something == $value): ?>
	< div class="ok">< /div>
<?php else: ?>
	< div class="ko">< /div>
<?php endif; ?>
]]>
http://blog.zurka.us/write-less-php-code/feed/ 0