3
Someone explains why this:
<?php
$world = _("World");
$str = <<<EOF
<p>Hello</p>
<p>$world</p>
EOF;
echo $str;
?>
generates this:
Hello
World
error-free?
what would that be <<<
, EOF
, <p>$world</p>
, _("World");
. Finally I wanted to understand what these things are that I’ve never seen developing in everyday life PHP
We can define anything after <<< EOF
?
It would be right to develop PHP
with html
using this?
if yes why? if not why ?
Example, instead:
echo "<table><tr><td>".$titulo."</td></tr></table>";
or so:
<table><tr><td><?php echo $titulo ?></td></tr></table>
Write that:
//tabela
$minha_tabela = <<<EOF
<table>
<tr>
<td>titulo e $titulo</td>
<tr>
<table>
EOF;
//apenas dando esse echo mostro minha tabela aonde eu quero
echo $minha_tabela;
As to the
_('world');
or it may be a user-defined function with that name or it is the extension to add translation to the site called gettext– rray
still has <p>$word</p> without echo
– Julio Henrique
the
<<<QUALQUERCOISA $variable QUALQUERCOISA;
will concatenate the variables you pass when you use theecho
. Is the same assprintf("Hello %s", $world)
orecho "Hello $world";
– Valdeir Psr
The
<p>$word</p>
this inside the EOF, so it is not PHP expression, but HTML saved inside the value of the variable– Guilherme Nascimento
Being correct or not is very relative. Actually these
<<<QUALQUER_COISA
is just one more way to print multiple lines with an interpolation/concatenation of variables. https://pastebin.com/xHn9bm2q . I use it this way when I do something incli
.– Valdeir Psr