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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:59:06+00:00 2026-06-14T09:59:06+00:00

Following the advice in this posting: php class as a plugin in wordpress I’ve

  • 0

Following the advice in this posting: php class as a plugin in wordpress

I’ve created a helper class for use with other plugins. In the class file, I have a declaration for activating the class, like:

function test_init() {

    $test = new Test();

} // End of test_init()

I’m able to access the functions in this class by doing something like:

Test::my_function();

However, I’m having issues referring to functions within this class from each other. For example:

function my_function() {

    Test::other_func();

}

In a case like this, I get the error message: “Function name must be a string”

I’ve tried $this->other_func, which returns the error: “there is not function “other_func” in the Class_Using_The_Test_Class.

I’ve tried self::other_func, which return the error: “Function name must be a string”

I tried using call_user_func() and I get: “call_user_func() expects parameter 1 to be a valid callback”

How do I call another function within this class?

  • 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-14T09:59:07+00:00Added an answer on June 14, 2026 at 9:59 am

    You don’t actually need to activate the class. I’ll give an example.

    Let’s say this code lives in helper-class.php:

    <?php
    
    class Helper_Class {
    
        // Note: those are double underscores before the word 'construct'.
        function __construct() {
    
            // initialize/call things here.
            $this->init(); // this is how you call class functions.
        }
    
        function init() {
            // do some monkey-business
    
            return;
        }
    
        // we'll call this function from our other class.
        function some_function() {
            // do the fancy whizbang.
        }
    }
    
    ?>
    

    Now, over in your other class file you could have something like this:

    <?php
    
    // give ourselves access to the helper class.
    require_once 'helper-class.php';
    
    class Main_Class {
    
        // Note: those are double underscores before the word 'construct'.
        function __construct() {
            $this->init();
        }
    
        function init() {
            // classes can't be used until an object of that class is created.
            $helper_class_object = new Helper_Class;
    
            // now I can call functions in my helper class.
            $helper_class_object->some_function();
    
            return;
        }
    
    }
    
    ?>
    

    I hope this sheds a bit of light on your situation. Just ask if you’d like further clarification. 🙂

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

Sidebar

Related Questions

I'm following this advice to clear a FILE input in IE (specifically using the
Following the advice in this link, Eclipse, classpath and subversion , I have setup
Wondering if I could get some advice and direction on this following requirement: Need
I need advice on how to change the file formatted following way file1: A
Following the advice of this page , I'm trying to get shared_ptr to call
I'm trying to create a subfolder structure in my app following this advice: Subdirectories
After following the advice in this question successfully, I added a couple additional lines
I'm following the advice in this post so that I can reference the HttpPostedFileBase
I've been following the advice in this question. How to add a WiX custom
I am following the advice from this webpage: http://www.formortals.com/build-qt-static-small-microsoft-intel-gcc-compiler to try and build the

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.