I have a PHP stuff that uses call_user_func to create element/objects to a certain function where it was place.
Example functions.php File:
function head($args=null){
echo $args;
}
function footer($args=null){
echo $args;
}
function createHeadTexts(){
echo 'This is header area';
}
function createFooterTexts(){
echo 'This is footer area';
}
//function to call this elements
function addParam($arg, $val){
call_user_func($arg, call_user_func($val));
}
Example index.php file:
head()
This is contents area...
footer()
Back to my functions.php file, I have added a call to function which is
addParam('head','createHeadTexts')//which is I thought has to be added on a header area.
addParam('footer','createHeadTexts')//which is I thought has to be added on a footer area too.
But I came to an issue when I tried to view my PHP page.
it looks like this :
This is header area This is footer area
This is contents area...
I thought the texts should be display like this:
This is header area
This is contents area...
This is footer area
The only functions should be place to my index.php file is head() and footer().
The head() should be appear before the web contents, and footer() should be appear after the contents.
If I would like to create an element/objects/scripts to head() it should be addParam(‘head’,’function to create element/object/scripts’);
Please help me how to fix this or is there any other way to use aside call_user_func?
Thanks,
I just tested this and it came out allright:
And the output:
Maybe you forgot to change some arguments? The only thing I changed was
addParam(‘footer’,’createHeadTexts’) to addParam(‘footer’,’create FOOTER Texts’)