|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-01-01 22:55 UTC] jani@php.net
-Status: Open
+Status: Wont fix
-Package: Feature/Change Request
+Package: Scripting Engine problem
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 08:00:01 2025 UTC |
Description: ------------ Hello, I would like to propose, as a new feature for PHP, the ability to set new or alternative start and end tags for PHP parsing (i.e. instead of the usual <?php and ?>). PHP tags are useful for including PHP inside HTML documents. Doing so makes it easier for designers to work directly inside PHP files with minimal risk that they mess up the code. However, a serious problem here is that PHP tags do not contrast clearly with the surrounding HTML code, since both the current PHP tags and HTML use brackets (< and >). One consequence for me is that I almost always tend to avoid writing PHP inside HTML; instead I print out long portions of HTML using PHP's echo statement. The solution to this dilemma would be to enable a function such as e.g. set_php_tags($new_start_tag, $new_end_tag), which would set new start and end tags for indicating start and end of PHP parsing. Using such a function somewhere at the top of my script, I could then perhaps write ##?php and ?## instead of <?php and ?> to start and end PHP parsing inside HTML code, which would make the PHP code contrast much clearer with the HTML code. Security consideration: As a security measure, I think that such optional tagging schemes perhaps only should be valid for the particular script files in which they are defined. (Otherwise, someone could perhaps set alternative tags in one script file, include a script file belonging to somebody else, and then have the whole script of that file be printed out as if it were HTML, since its PHP parsing tags would be ignored.) Thomas Reproduce code: --------------- <?php set_php_tags("##?php", "?##"); $string = "Hello World!"; ?> Here is some text:<br> ##?php echo $string; ?##<br> End Expected result: ---------------- Here is some text: Hello World! End