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.
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)
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.
I'm following a PHP/AJAX tutorial on form validation. (I'm new to php!).
Could someone explain the syntax of this line:
<?=#$_REQUEST['username']?>
The context is the value attribute of an input field.
I know how $_REQUEST works. I just don't get the <?=# part. I understand <? can be used in lieu of <?php (but isn't always supported!) and <?=$variable?> is special syntax for echoing variables. What does the # symbol do?
Thanks.
Links:
Form validation tutorial
Explanation for special syntax
<?= ?> is the short echo syntax. <?=$var?> is equivalent to <?php echo $var; ?>.
From the PHP 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.
# is the error suppression operator. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.
In short, <?=#$_REQUEST['username']?> will try to print out the value of $_REQUEST['username'] (without ouputting any errors). It's not a good practice and shouldn't be used in your code. If you don't want to display the errors, turn off display_errors in your php.ini configuration and log them instead.
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!
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Reference - What does this symbol mean in PHP?
I don't know if this has been asked before, but here goes: What's the difference between <?php, <?=, and <??
I'm just curious, and people have been telling me to use <?php instead of <?, but I just use <? because it works for me and it's faster. I ain't seein' no diff'rence (redneck accent for extra pleasures...).
<?php and <? are equivalent, except it's generally preferred to use <?php since not every server configuration may have the short opening PHP tags option enabled.
<?= is a shortcut for echoing back the value of a variable/expression, i. e.
<?=$var ?>
is similar to
<?php echo $var; ?>