I'm trying to printing data from a database to the hcard format:
...
<span class='n'>
<span class="given-name">John</span>
...
</span>
Then I created this php function:
function print_row ($html_tag, $type, $value) {
echo '<'.$html_tag.' class="'.$type.'">'.$value.'</'.$html_tag.'>';
}
// Calling function
print_row('span', 'given_name', 'John');
// Output
<span class="given_name">Nathan</span>
This worked as I expected until I tried calling my print_row
function as a parameter of the print_row
function.
print_row('span', 'n', print_row('span', 'given_name', 'Nathan'));
// Output
<span class="given_name">Nathan</span>
<span class="n"></span>
// Wanted Output
<span class="n"><span class="given_name">Nathan</span></span>
- Why is my second 'print_row' function call not inside my first'print_row' function call?
- Is this even impossible? (PHP - Can I pass a function name as a function argument?)