note 128827 added to control-structures.alternative-syntax
| From: | albaash247 at gmail dot com | Date: | Thu, 24 Aug 2023 04:40:05 +0000 |
| Subject: | note 128827 added to control-structures.alternative-syntax | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220789@lists.php.net to get a copy of this message | ||
i was wondering which solution is better (using heredoc or Alternative syntax). Anyway, you can use
heredoc to populate data like this:
<?php
function printUsers()
{
require_once '../API/get-users.php';
foreach (getResponse() as $user) {
$template = <<<HTML
<tr id="userRowTemplate">
<th id="txtUserId" scope="row" >$user[id]</th>
<td id="txtUserFullName">$user[full_name]</td>
<td id="txtUserEmail">$user[email]</td>
<td id="action">
<button id="btnEnable">Enable</button>
<button id="btnDisable">Disable</button>
</td>
</tr>
HTML;
echo $template;
}
}
?>
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.134 (proxied: 2001:1670:10:1528:3c35:ea26:5292:b9b0)
----
Manual Page -- https://php.net/manual/en/control-structures.alternative-syntax.php
Edit -- https://main.php.net/note/edit/128827
Del: integrated -- https://main.php.net/note/delete/128827/integrated
Del: useless -- https://main.php.net/note/delete/128827/useless
Del: bad code -- https://main.php.net/note/delete/128827/bad+code
Del: spam -- https://main.php.net/note/delete/128827/spam
Del: non-english -- https://main.php.net/note/delete/128827/non-english
Del: in docs -- https://main.php.net/note/delete/128827/in+docs
Del: other reasons-- https://main.php.net/note/delete/128827
Reject -- https://main.php.net/note/reject/128827
Search -- https://main.php.net/manage/user-notes.php