3 ms·
PHP started life as a template engine for CGI applications written in C. And some pretty major projects like WordPress use PHP as a "template language". There
by arp242 5y ago
PHP started life as a template engine for CGI applications written in C. And some pretty major projects like WordPress use PHP as a "template language".
There are various constructs in the language rarely seen in PHP code that make this easier, such as <?=, but also also "if (..):" which can be ended with "endif", and "foreach (...):" which can be ended with "endforeach".
It's not a hard feature to add. PHP devs want to move away from this "PHP as a template language" (I think they tried to remove the <?= a few years back); that's all fine, but fact of the matter is that people ARE using it as a template language and will continue to do so in the foreseeable future. Not supporting that with something as simple as "automatic escape special HTML characters" is extremely disappointing, and would actually prevent a lot of problems.
- DaiPlusPlus 5y ago"I think they tried to remove the <?= a few years back)" Not quite. They deprecated `<?` but not `<?=`, see here: https://wiki.php.net/rfc/deprecate_php_short_tags https://wiki.php.net/rfc/deprecate_php_short_tags Another PHP-RFC removed `<%`, `<%=`, and `<script language="php">` (I'll admit I didn't know about that one): https://wiki.php.net/rfc/remove_alternative_php_tags https://wiki.php.net/rfc/remove_alternative_php_tags - but as with before, this specifically retained `<?=`.
- arp242 5y agoAh yes, it was just the "<?" tag and not "<?="; I misremembered. The ASP tags were always a bit of a misfeature; I don't think I've ever seen it used even once. <script language="php"> is just weird because it's intended for client-side scripts :-/