php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #48844 Ability to set new/alternative PHP parse tags
Submitted: 2009-07-08 05:07 UTC Modified: 2011-01-01 22:55 UTC
From: tcjohans at riseup dot net Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 5.2.10 OS: Windows Vista
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tcjohans at riseup dot net
New email:
PHP Version: OS:

 

 [2009-07-08 05:07 UTC] tcjohans at riseup dot net
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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-01 22:55 UTC] jani@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: Scripting Engine problem
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 14:01:28 2024 UTC