Much like asp.net's <%=SomeVariable%> how can i enable <?php =SomeVariable ?> ?
Currently my app only works if i do <?php echo(SomeVariable) ?>
Iam using php 5.1.6
Thanks
Much like asp.net's <%=SomeVariable%> how can i enable <?php =SomeVariable ?> ?
Currently my app only works if i do <?php echo(SomeVariable) ?>
Iam using php 5.1.6
Thanks
I believe you're looking for short_open_tag
Note that using short tags is generally considered bad practice because it reduces code portability. It's best to use the standard <?php echo "..."; ?> as this will run regardless of server settings.
Try not to use the ASP style open/close tags as there is a possibility that they will be deprecated in PHP 6.
Unfortunately, php has no <?php= syntax. You either turn on short_open_tag and get <? and <?= or, you do it the sadly, proper way and do <?php print(); ?> or <?php echo();?>.
Some people (and frameworks) do a little syntactic sugar like this:
function p($toPrint) {
print($toPrint);
}
and that allows:
<?php p($message) ?>
But short tags really aren't desirable. Possible future deprication is one reason, but the other is that <? is the start of an XML declaration as well, and that can cause problems when you're doing this for XHTML:
<?xml version="1.0" encoding="UTF-16"?>
you'll get a nasty PHP error.