This was probably asked earlier, but I could not find the answer to my question with some preliminary searches, so here it is:
A very simple example of my current method of entering PHP variables into HTML is as follows:
HTML (file.php):
<tag><?php echo $variable; ?></tag>
PHP:
$variable = "value";
ob_start();
include "file.php";
$results = ob_get_clean();
This allows me to get the correct result, but it annoys me every time I have to copy and paste these three lines to get the variables embedded in my HTML files. I probably want to change the details of this injection function to a later date, and it is currently scattered in several hundred places throughout my code.
, "". , . , :
function injectVariables($filePath, array $variables)
{
extract($variables);
ob_start();
include $filePath;
return ob_get_clean();
}
, , , , , , . , , , .
- - , ?