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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:39:42+00:00 2026-06-05T03:39:42+00:00

ok I have this code, that I’m studying class scope{ function printme(){ return hello;

  • 0

ok I have this code, that I’m studying

 class scope{

    function printme(){
        return "hello";
    }

    public static function printme(){
        return "hello"; 
    }

 }

$s = new scope();
echo $s->printme(); //non-static call
echo "<br>";
echo scope::printme(); //static call

Now, this is not really the code of my project but these are the things I want to do

  1. I want to create a class the will contain static and non-static functions.
  2. I want a function to be available both on static and non-static calls.

As non-static function has a lot of operations on it, I also need to call it as a static function so that I will not need to instantiate the class. Is this possible? or I really needed to rewrite the function to another function or class?

NOTE: tell me if I’m doing some bad programming already.

  • 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-05T03:39:44+00:00Added an answer on June 5, 2026 at 3:39 am

    Here is the rule:

    A static method can be used in both static method and non-static method.

    A non-static method can only be used in a non-static method.

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

Sidebar

Related Questions

I have this code that multiplies 32 bit * 32 bit. public static void
I have this code that's supposed to unzipp a file. public class dec extends
I have this code that works. public class HelloWorldController : Controller { UAStagingEntities db
I have this code that saves a pdf file. FileStream fs = new FileStream(SaveLocation,
I have this code that will check for if the class more-results are in
I have this code that will return keyword suggestion from yahoo using the api.
i Have this code that select all checkboxes: <html> <head> <script language=javascript> function checkAll(){
I have this code that works my @new = keys %h1; my @old =
I have this code that works from an .as file if (loaderInfo.loader) loaderInfo.loader.dispatchEvent(new Event(pageFinish,
I have this code that I want to insert a div clear class 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.