From:             tcjohans at riseup dot net
Operating system: Windows Vista
PHP version:      5.2.10
PHP Bug Type:     Feature/Change Request
Bug description:  Neater insertion of PHP variables in HTML

Description:
------------
Hello,

Here is an idea of how to facilitate the interaction between PHP and HTML
code. Much of this interaction just has to do with the insertion of the
value of a previously defined PHP variable into the HTML document.
Currently, this is done through a rather roundabout coding:

<?php echo $somevariable; ?>

This snippet contains 28 characters, i.e. 16 more than the 12 of the
variable name. Could it be put neater and more economical?

I think so. I would propose a shorter format: 
A simple prefix that simply just tells PHP that what immediately follows
is a PHP variable whose value should be inserted into the HTML document,
but that in all other regards this is just HTML code.
There should also be a closing suffix (but this is perhaps mostly to give
an aesthetically balanced coding.)

E.g. a prefix like "<$php:" and a suffix like ">" (or whatever), so that
one could just write something like

<$php:somevariable>

in the HTML code in order to have the value of $somevariable to be
inserted there.

The 28 characters of the usual way has now become just 19 characters. And
the whole snippet is much more concise and clearer: it gives a neater
appearance within the surrounding HTML code, which facilitates for the
developer/designer.

This would simply be so much more economic and neater than the usual way.

The idea can be extended:

For instance, in order to call a function somewhere in a piece of HTML
code, one might perhaps do something like this:

<?php:somefunction($var1, $var2)>

Thomas

Reproduce code:
---------------
<?php

function goodbye($a) {
 echo "Goodbye " . $a . "!";
}

$greeting = "Hello World!";

?>

This is some HTML text.<br>
Followed by:<br>
<$php:greeting><br>
<$php:goodbye("world")><br>
End



Expected result:
----------------
This is some HTML text.
Followed by:
Hello World!
Goodbye world!
End


-- 
Edit bug report at http://bugs.php.net/?id=48848&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=48848&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=48848&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=48848&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=48848&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=48848&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=48848&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=48848&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=48848&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=48848&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=48848&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=48848&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=48848&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=48848&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=48848&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=48848&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=48848&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=48848&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=48848&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=48848&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=48848&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=48848&r=mysqlcfg

Reply via email to