Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8180415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:12:33+00:00 2026-06-07T00:12:33+00:00

I have a PHP stuff that uses call_user_func to create element/objects to a certain

  • 0

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,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T00:12:35+00:00Added an answer on June 7, 2026 at 12:12 am

    I just tested this and it came out allright:

    <?php
    
    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));
    }
    
    addParam('head','createHeadTexts');
    echo '<br />This is contents area...<br />';
    addParam('footer','createFooterTexts');
    
    ?>
    

    And the output:

    This is header area
    This is contents area...
    This is footer area
    

    Maybe you forgot to change some arguments? The only thing I changed was

    addParam(‘footer’,’createHeadTexts’) to addParam(‘footer’,’create FOOTER Texts’)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php file that is only accessed through ajax. The ajax call
i have a controller that have with in let's say thingy/stuff directory <?php public
I have a rather big php script that uses the foreach loop pretty often.
I have a PHP process that does a bunch of stuff and I want
I have a resize script i made in PHP that uses GD (my VPS
i have a PHP application that uses $_SESSION global to manage data inside the
I have been doing PHP stuff for almost one year and I have never
I have a page called send.email.php which sends an email - pretty simple stuff
I have a page called send.email.php which sends an email - pretty simple stuff
I have php code that puts some values into an Array as follows: $hunter=addslashes($MessageArray[1]);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.