Edit report at http://bugs.php.net/bug.php?id=48844&edit=1

 ID:                 48844
 Updated by:         [email protected]
 Reported by:        tcjohans at riseup dot net
 Summary:            Ability to set new/alternative PHP parse tags
-Status:             Open
+Status:             Wont fix
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            Scripting Engine problem
 Operating System:   Windows Vista
 PHP Version:        5.2.10
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2009-07-08 05:07:52] 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



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=48844&edit=1

Reply via email to