ID: 48848
Updated by: [email protected]
Reported By: tcjohans at riseup dot net
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: Windows Vista
PHP Version: 5.2.10
New Comment:
Uhm, are you not aware that we have this already in the form of:
<?= ?>
Previous Comments:
------------------------------------------------------------------------
[2009-07-08 08:02:20] tcjohans at riseup dot net
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 this bug report at http://bugs.php.net/?id=48848&edit=1