note 126834 added to function.echo
| From: | retrobytespr at mail dot com | Date: | Tue, 08 Feb 2022 09:39:36 +0000 |
| Subject: | note 126834 added to function.echo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-217588@lists.php.net to get a copy of this message | ||
If you have a large block of text, say your blog or something includes code examples, you may use
the <<< operator (?) to define the start and end of your block to be echoed out. For
instance:
<?php
echo <<< JAVASCRIPT
function convertTroyOuncesToGrams(troyOunce) {
return troyOunce / 31.1034768;
}
JAVASCRIPT; # End of block
?>
You may also embed PHP strings and other simple scalars into your blocks of text, for example:
<?php
$troyOunceAsGrams = 31.1034768;
echo <<< JAVASCRIPT
function convertTroyOuncesToGrams(troyOunce) {
return troyOunce / {$troyOunceAsGrams};
}
JAVASCRIPT;
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.135 (proxied: 82.68.30.35)
----
Manual Page -- https://php.net/manual/en/function.echo.php
Edit -- https://main.php.net/note/edit/126834
Del: integrated -- https://main.php.net/note/delete/126834/integrated
Del: useless -- https://main.php.net/note/delete/126834/useless
Del: bad code -- https://main.php.net/note/delete/126834/bad+code
Del: spam -- https://main.php.net/note/delete/126834/spam
Del: non-english -- https://main.php.net/note/delete/126834/non-english
Del: in docs -- https://main.php.net/note/delete/126834/in+docs
Del: other reasons-- https://main.php.net/note/delete/126834
Reject -- https://main.php.net/note/reject/126834
Search -- https://main.php.net/manage/user-notes.php