Hacker News new | past | comments | ask | show | jobs | submit login

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; ?>



Yes, 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").


I agree!


PHP can only be used serverside, no? Can't write single page apps.


You can't do SPAs with ajax calls?


Huh? I'm asking how with PHP. You would write a 100% client side app.


You can't use JSP to make a SPA, either. I was replying to the statement "Angular is for n00bz"




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: