This question already has answers here:
What does '<?=' mean in PHP?
(8 answers)
Closed 9 years ago.
I recently discovered some code that output a variable in php like this:
<?=$var;?>
I have never seen this before. Is it the same as
<?php echo $var;?>
?
<?=$var;?>
is the same as
<?php echo $var;?>
But it will only work if you have:
short_open_tag=On
in your php.ini
As of php 5.4 short_open_tag isn't required. The shorthand version is always available. http://php.net/manual/en/ini.core.php#ini.short-open-tag
#jszobody: Thanks for your comment!
Related
This question already has answers here:
Reference Guide: What does this symbol mean in PHP? (PHP Syntax)
(24 answers)
Closed 7 years ago.
For printing any PHP variable the following syntax is used sometimes
<?= $x ?>
Can anyone please explain when should I use this instead of
<?php echo $x; ?>
and what the name of that operator <?= ?
Any help is appreciated.
it's fast echo.
You can use it with html.
<div class="<?=$your_class"></div>
It's a "short tag"; this one is an abbreviation for "<?php echo". You need to be careful when using it or any other short tags as not all servers are configured to render them correctly.
A bit more info can be found here: http://php.net/manual/en/language.basic-syntax.phptags.php
This question already has answers here:
Reference Guide: What does this symbol mean in PHP? (PHP Syntax)
(24 answers)
Closed 8 years ago.
I am learning php and Ajax, but I see a code where <? is used.
<?php while($row=mysql_fetch_array($result)) { ?>
<option value=<?=$row['id']?>><?=$row['statename']?></option>
Please could you help me to understand why is
You can use
<?=$row['statement'] ?>
as a convenient shorthand to
<?php echo $row['statement'] ?>
this can improve readability.
Read the manual.
It will explain everything about tags.
http://www.php.net/manual/en/language.basic-syntax.phpmode.php
This question already has answers here:
Reference Guide: What does this symbol mean in PHP? (PHP Syntax)
(24 answers)
PHP echo vs PHP short echo tags
(6 answers)
Closed 9 years ago.
What is the use of the following symbols in php?
<?= code($data); ?>
Though I don't know the actual use of the above symbol, I found out that I can use
<?= my_function($data1,$data2); ?>
instead of using
<?php echo my_function($data1,$data2); ?>
Can anyone explain what exactly is happening here and what is the use of it?
It's a quick way of echoing text, as that's one of the most common uses of PHP.
As of PHP 5.4, <?= ?> is essentially the short-hand way of writing <?php ?>.
This question already has answers here:
Reference Guide: What does this symbol mean in PHP? (PHP Syntax)
(24 answers)
Closed 9 years ago.
Previous I bumped into codes like this:
<?php
$var="hello";
?>
<?=$var?>
It simply prints out the content of $var, so... is the syntax equivalent to echo $var?
I'll also appreciate an answer pointing to a related manual page. Since the syntax is not searchable.
Yes, <?=$var?> is the same as <?php echo $var; ?>
From PHP.net manual: echo also has a shortcut syntax, where you can immediately follow the opening tag with an equals sign. Prior to PHP 5.4.0, this short syntax only works with the short_open_tag configuration setting enabled.
You can read more here.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
What does '<?=' mean in PHP?
I'm reading someone else's code and I don't think I've come across this before.
if((< ? =date("Y");?>-parseInt($('#year').find('option:selected').val()))<18)
Any thoughts?
Thanks
<?= is the short open and echo tag. Here is the PHP documentation for it.
<?= is short-hand for <?php echo, but only works if php.ini is setup properly.
Same as <?php echo ...
It is not always enabled in some environments.
That evaluates to:
if((<?php echo date("Y"); ?>-parseInt($('#year').find('option:selected').val()))<18)
But I think its recommended for you to use <?php echo '';?> instead of <?= ?> for compatibility reasons.