just text<br />
{_server.DOCUMENT_ROOT}<br />
{a_var}<br />
just text<hr />
folders are separated by either \ or /<br />
{if _const.DIRECTORY_SEPARATOR = '/'}on this server it is a slash
{else}on this server it is a backslash
{endif}<br />
one more constant: {_const.__FILE__}<br />
finished
get's converted to
$result = 'just text<br />
'.$_SERVER['DOCUMENT_ROOT'].'<br />
'.$data['a_var'].'<br />
just text<hr />
folders are separated by either \\ or /<br />
'.((DIRECTORY_SEPARATOR == '/') ? 'on this server it is a slash
' : 'on this server it is a backslash
').'<br />
one more constant: '.__FILE__.'<br />
finished';
by my template engine
to avoid ugly error messages i won't to prepend these lines
if (!isset($_SERVER['DOCUMENT_ROOT'])) $_SERVER['DOCUMENT_ROOT'] = NULL;
if (!isset($data['eine_variable'])) $data['eine_variable'] = NULL;
if (!defined('DIRECTORY_SEPARATOR')) define('DIRECTORY_SEPARATOR', NULL);
if (!defined('__FILE__')) define('__FILE__', NULL);
Suppressing error message by using error_reporting(0); is no option becuase it slows down the code (error still occurs, php looks for an error handler, ...)
So I need to detect all vars and constants used in th etemplate.
I can look at the produced code and find anything starting with $.
This way I don't find any constants used.
I can look at the template and search for anything between { and }
This way I get everything except DIRECTORY_SEPARATOR, cause it's not used as a "plain" constant but it's ued in an if-statement.
So where and how do I find the two vars and the two constants used?
In the template? If so: How?
In the produced code? If so: How?
tia