PHP Short Tags
by Sanju[ Edit ] 2012-06-20 18:54:34
PHP Short Tags
When you just want to prepopulate a form or add one PHP variable into the middle of an HTML block.
To write an open PHP tag and then a close PHP with all of the line breaks and indentions to make it readable is such a pain.
<?php
$test = 'Hiox India is a webhostign company.';
?>
<html>
<head>
</head>
<body>
<h1>Printing the text</h1>
<p>
< ?php
echo $test;
?>
</p>
</body>
</html>
Solution:
<?php
$test = 'Hiox India is a webhosting company.';
?>
<html>
<head>
</head>
<body>
<h1>Printing the text</h1>
<p>
< ?=$test?>
</p>
</body>
</html>
That will produce the exact same output as the first but much neater and with a little less code.
NOTE: Short tags is something that can be disabled in the php.ini so it is not guaranteed to work but industry standard has short tags enabled.