4 ms·
PHP also offers a nice way to write templates without even having to use echo and without braces: <?php foreach($x as $y): ?> <h1><?= $y->title ?></h1> <
by raboukhalil 10y ago
PHP also offers a nice way to write templates without even having to use echo and without braces:
<?php foreach($x as $y): ?>
<h1><?= $y->title ?></h1>
<?php endforeach; ?>
- bluejekyll 10y agoPHP can only be used serverside, no? Can't write single page apps.
- goatlover 10y agoYou can't do SPAs with ajax calls?
- bluejekyll 10y agoHuh? I'm asking how with PHP. You would write a 100% client side app.
- g00gler 10y agoYou can't use JSP to make a SPA, either. I was replying to the statement "Angular is for n00bz"
- combatentropy 10y agoYes, that's what I do. I also think it's fine to use omit trailing semicolons and to use short-open tags (I already labelled the file .php --- why do I have to keep saying "php" all over it? And I'm not usually outputting XML.) <? foreach($x as $y): ?> <h1><?= h($y->title) ?></h1> <? endforeach ?> You just want to make sure to escape all output with htmlspecialchars, or define a shorter function like I did ("h").
- raboukhalil 10y agoI agree!