So I have the following line...
<?=$variable?>
Is there a way to change it to long tags without typing a full echo statement?
<?php=$variable?> doesn't work
I know that <?php echo $variable ?> will work, but is there a shorter way to do it?
So I have the following line...
<?=$variable?>
Is there a way to change it to long tags without typing a full echo statement?
<?php=$variable?> doesn't work
I know that <?php echo $variable ?> will work, but is there a shorter way to do it?
What?
The short way to do it is <?= ... ?>. Which is equivalent to <?php echo ... ?>.
That's all there is to it.
Is there a way to change it to long tags without typing a full echo statement?
No
Edit: For Strager http://bugs.php.net/bug.php?id=27448&edit=1
The shorter way is to use tokenized replacements (via a templating system, like Smarty) instead of interpolating between php and html syntax. Tokens are cleaner in general, and they don't have to be complicated.
Your HTML would look like:
<html>
<head>
<title>%title_token%</title>
</head>
<body>
<div id="content">%content_token%</div>
<div id="footer">%footer_token%</div>
</body>
</html>
etc. Different templating systems use different tokens (Smarty uses a several-step define, parse, compile), but all you really need is str_replace:
str_replace($template, '%title_token%', 'Super Awesome Webpage');