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 8502105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:23:34+00:00 2026-06-11T01:23:34+00:00

$scripts[0] = ‘Say Hello’; $scripts[1] = ‘Dont Say Hello’; $scripts[2] = ‘Welcome’; $function_name =

  • 0
$scripts[0] = 'Say Hello';
$scripts[1] = 'Dont Say Hello';
$scripts[2] = 'Welcome';

$function_name = str_replace(' ', '_', $scripts[0]);   //Name of the function "Say_Hello"

echo $function_name('Jolly');   // Should echo "Hello Jolly"

I have a huge array with full of names which are associated with functions. In normal ways, if we are to call the function Say_Hello(), we do like this : Say_Hello(‘Jolly’). But in my case above, the name of the function is stored in a variable so how can I call it?

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-11T01:23:35+00:00Added an answer on June 11, 2026 at 1:23 am

    Check out PHP function call_user_func :

    call_user_func — Call the callback given by the first parameter

    example:

    <?php
    error_reporting(E_ALL);
    function increment(&$var)
    {
        $var++;
    }
    
    $a = 0;
    call_user_func('increment', $a);
    echo $a."\n";
    
    call_user_func_array('increment', array(&$a)); // You can use this instead before PHP 5.3
    echo $a."\n";
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have 2 scripts test1.sh #!/bin/sh . ./test2.sh foo test2.sh #!/bin/sh foo(){ echo
CGI scripts should have access to a list of environment variables set by the
Included Scripts <script src=../../Scripts/jquery-ui-1.8.17.custom.min.js type=text/javascript></script> Accordion Script ` $(function () { $(#accordion).accordion(); }); $(#tabs).tabs();
My scripts are definitely saved in UTF-8. I'm instantiating PDO with {$this->engine}:host={$this->host};dbname={$this->name};charset=UTF-8 . My
My zend layout and scripts are detecting fine. but when in init function of
Scripts var timer; var firing = false; var begen = function(id) { alert('one click');
In jquery scripts i often see functions called like this: var somefunction = function(){
i have 2 scripts running on my website. each do a certain function but
I know PHP scripts don't actually compile until they are run. However, say I
All my js scripts are working, but this is not working $(img).each(function() { if

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.