Last active
November 6, 2024 19:26
-
-
Save Pephers/7910835 to your computer and use it in GitHub Desktop.
How to call a PHP function inside a Heredoc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$cb = function ($fn) { | |
return $fn; | |
}; | |
echo <<<HEREDOC | |
Hello, {$cb(ucfirst('world'))} | |
HEREDOC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also, there are a lot of options:
https://stackoverflow.com/questions/104516/calling-php-functions-within-heredoc-strings/36202673#36202673