I have this function :
function MakeInput($id, $class) {
$value = substr($id, 2);
global $$value;
echo '<input type="text" id="'.$id.'" name="'.$id.'" class="'.$class.'" value="'.htmlentities($$value,ENT_COMPAT,'UTF-8').'" />';
}
Which do not return but echoes the results.
I’d like to use it as it is into another function:
function ItkMakeMo($NomDebVar) {
$Output = '
<tr>
<td>Test</td>
</tr>
<tr>
<td>'.MakeInput($NomDebVar.'moshj','IntInput').'</td>
</tr>
';
echo $Output;
}
So this solution doesn’t work, PHP sends the MakeInput output before the “echo $Output”
If for some reason you can’t change
MakeInput()or it would take more effort than it’s worth to change it, then you can echo the output directly fromItkMakeMo():Then the
MakeInput()output would be in the right place.If possible, it’s usually better not to directly output in functions and instead return the output as a string, then you can output it when you call the function.