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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:51:30+00:00 2026-05-16T04:51:30+00:00

If I write a public static method in a class ie… public static function

  • 0

If I write a public static method in a class ie…

public static function get_info($type){
        switch($type){
            case'title':
                self::get_title(); 
                break;
        }
    }

I have to write my get_title() function as public…

public static function get_title(){
        return 'Title';
    }

Otherwise I get the error:

Call to private method Page::get_title()

Which makes me feel as though the function get_info() is essentially redundant. I’d like to be able to make a call from a static method to a private method inside my class for validation purposes. Is this impossible?

PHP > 5.0 btw.

!####### EDIT SOLUTION (BUT NOT ANSWER TO QUESTION) #########!

In case you are curious, my workaround was to instantiate my static function’s class inside the static function.

So, the class name was Page I would do this…

public static function get_info($type){
            $page = new Page();
            switch($type){
                case'title':
                    $page->get_title(); 
                    break;
            }
        }
  public function get_title(){
            return 'Title';
        }
  • 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-16T04:51:31+00:00Added an answer on May 16, 2026 at 4:51 am

    yes, it’s impossible – a non-static method needs an object to read data from, while the point of a static one is that it has no such object attached. you can think of each non-static method of being passed an implicit argument, the object. you simply don’t have a value to pass this value on to the method if you’re calling from a static function.

    update
    you can have private static function – I’m not sure if your question might involve a slight misunderstanding of private and static as mutually exclusive concepts

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

Sidebar

Related Questions

I'm trying to write a method like this: public static T Test<T>() { if
using System; using System.Math; class test { public static void Main() { Console.Write(Enter any
I'm trying to write a test for the following method: public class Sort {
I have this static method on C# : public class MyClass { public MyClass()
I wrote two methods in class Util: public static final <T> T[] copy1(T[] source)
I'm following tutorial, installed RanvenDB embeeded and write: public static IDocumentStore archives = new
I am using this code to write asynchronously to a file public static void
Okay, so i have this code i wrote: class Connection { public static StreamWriter
I have this class: public static class CsvWriter { private static StreamWriter _writer =
public class createExcel { public void write() throws IOException, WriteException { WorkbookSettings wbSettings =

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.