|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-07-08 08:08 UTC] derick@php.net
[2009-07-08 10:19 UTC] tcjohans at riseup dot net
[2009-07-08 10:29 UTC] tcjohans at riseup dot net
[2009-07-08 10:47 UTC] tcjohans at riseup dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 20:00:02 2025 UTC |
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