I'm facing a problem to call PHP function from html code and fill arguments of function. After that the HTML code is output with returned values of functions.
for an example:
somewhere In PHP file are defined functions
function html_field($type,$name,$value){
//some code here
return $out;
}
// or other example function
function boldme($text){
return "<b>$text</b>";
}
After that is generated html output in string with php functions inside (like tags)
HTML String:
$html = "<h1><label for="foo">{call~html_field("text","name","value")} </label><input type="text" name="foo" id="foo" /> </h1>"
OR
$html = "<h1><label for="foo">{call~boldme("text")} </label><input type="text" name="foo" id="foo" /> </h1>"
The solution should ends, like:
$html = "<h1><label for="foo"><input type="text" name="name" ...> </label><input type="text" name="foo" id="foo" /> </h1>"
OR
$html = "<h1><label for="foo"><b>text</b> </label><input type="text" name="foo" id="foo" /> </h1>"
It is required to filter this string...
NOTE: The string containing the collected html data from templates and themes, they are unknowable files with pure HTML inside.
I was using preg_replace_callback to create needed functionality, but all gone now, thanks to my boss.... !@#!
preg_replace_callback()overeval()any day.<?php echo myFunc($value); ?>isn't enough?