I have tested the following and it doesn't work. Is there a similar way of achieving this?
A compiling class which formulates a template:
private function include_header () {
function _metadata () {
// Metadata compiler
return $metadata;
}
include (path . "header.php");
}
header.php
<html>
<head>
<?php
_metadata ();
?>
<title>Hello Stackoverflow!</title>
</head>
<body>
...
The _metadata ();
function is only available within the include_header ();
function - nowhere else in the class. I don't want to have to write $this->_metadata ();
in the template file only _metadata ();
. Is that achievable?
Alternatively one could create an external file, for example functions.php
which has the underscore functions specifically for the template - but I'd much rather see if the original query is possible.
Thank you in advance.