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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:31:01+00:00 2026-05-23T20:31:01+00:00

I declared class which has 1 object . calling method with that object is

  • 0

I declared class which has 1 object . calling method with that object is okay , but calling methods which was not-an-object causing no output .. here it demonstrates

    
                // defining simple class
            class Person{ 
            function say_hello($name='world')
                {
                    echo "hello {$name}";

            }
        }

        $instant1 = new Person();

        $object2 = new Person();

        echo get_class($object2);
        ?>
<br/>
<?php 

if(is_a($object2,'Person'))
{
//remeber to pass arguments 
echo "This object or instant is in that class";
}
else {

echo "No dude :( ";
}

?>



<?php 


$instant1->say_hello('Paritosh');

echo " <br/>";

$ob->say_hello(); // No error No output , even there is no object with name $ob and below code is not running
// is it bug or any concept ?

echo "No output ";
$object2->say_hello();

?>

I’m using PHP Version 5.2.17 in IIS Express in webmatrix platform .

  • 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-23T20:31:02+00:00Added an answer on May 23, 2026 at 8:31 pm

    $ob ist not a Person, so how should the interpreter know that you want access Person?
    if you want to access the function without an object, try:

    Person::say_hello();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A class which has a method declared as this: public class A{ public <T>
I have a marshmallow class which has (among other things) a CCSprite object as
I have a class that offers up a few events. That class is declared
How can i check to see if a static class has been declared? ex
In Flex (and many other languages) a function/method of a class can be declared
This is not an actual Xcode error message, it is a warning that has
I have a class A which has the following: public class A { [Import(typeof(IMyService)]
I have a DirectoryMonitor class which works on another thread. It has the following
It is not possible to create an object by directly calling the constructor of
If I have a class Person which has two instance variables: name of type

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.