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

  • Home
  • SEARCH
  • 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 7490421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:36:07+00:00 2026-05-29T15:36:07+00:00

I dont understand the function, call_user_func() in the sense that i get how it

  • 0

I dont understand the function, call_user_func() in the sense that i get how it works but I’m not sure why its required or in what context to use it in php. As far as I’m concerned why not just call the function instead of calling a function with a function? Thnx!

  • 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-05-29T15:36:08+00:00Added an answer on May 29, 2026 at 3:36 pm

    I’ve had a couple situations where this was very necessary. For example, when I was creating a project that allowed a user to construct parts of a programming language, the system would wrap the “tag” definition in a function before running it for security reasons. However, in doing this, I can’t simply call those functions, because I don’t know when I need to call them, or even what the names would be. Enter call_user_func()…

    So, I’m sure you’re confused right now. Let me explain. What my system did, was take some XML, and convert it into PHP/HTML/JS with PHP. This allowed for rapid creation of GUIs (which was the goal). Take this XML for example:

    <window id="login-win" title="Access Restricted" width="310" height="186" layout="accordion" layoutConfig="animate:true">
        <panel id="login-panel" title="User Login">
            <form id="login-form" title="Credentials">
                <textbox id="login-uname" label="Username"/>
                <password id="login-pass" label="Password"/>
                <submit text="Login"/>
            </form>
        </panel>
        <panel id="login-register" title="Register">
            Nothing, you can't register!
        </panel>
    </window>
    

    Each XML tag would be read, then fed into it’s corresponding PHP function. That function would determine what to do for that 1 tag. In order to pull this off, I had files each named after the tag it handled. So, for example, the tag’s file was “submit.php”. This file’s contents would get wrapped in a generated function, something like:

    function tag_submit($variables, $parent, $children){
    
        // deal with the data, then echo what is needed
    
    }
    

    This function’s name would be stored in an array, with it’s associated tag name, with the rest of the generated functions. This makes it so the function is generated once, and only created when needed, saving memory, since I would do a if(func_exists()) call to determine if I needed it or not.

    However, since this is all dynamic, and the user may want to add in a new tag, for say, a < date > tag, I needed to use call_user_func() to get things to work. I can’t hard-code a function call if I don’t know what the name is.

    Hope that all made sense. Basically, yes, it is a rarely used function, but it is still very very useful.

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

Sidebar

Related Questions

I want to use the status method but i dont understand how it works.
This code works, but i dont understand why. With DeferredLoadingEnabld = false, I would
I'm trying to understand the basic MVVM design approach, but I dont' understand where
I don't understand this: I use the __autoload feature in php and this works:
I'm fairly new to C++ and don't quite understand function parameters with pointers and
I don't understand why C#'s Main function is void by default (in a console
I don't understand the last line of this function from Programming Perl 3e .
I came across this JavaScript function and I don't understand quite what it's doing,
i dont understand the problem with returning multiple rows: here is my table BBC:
I dont understand what would be the problem with the following code. It needs

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.