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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:00:43+00:00 2026-06-14T02:00:43+00:00

$obj = new stdClass(); echo gettype($obj); //object function abc(object $obj) { return; } abc($obj);

  • 0
$obj = new stdClass();
echo gettype($obj); //object

function abc(object $obj) {
    return;
}

abc($obj); //Catchable fatal error: Argument 1 passed to abc() must be an instance of object, instance of stdClass given

Why calling abc($obj) triggers error?

Catchable fatal error: Argument 1 passed to abc() must be an instance of object, instance of stdClass given

  • 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-14T02:00:45+00:00Added an answer on June 14, 2026 at 2:00 am

    Since PHP 5 (Jul 2004; Zend Engine 2) type hinting worked only for class and interface names, array (PHP 5.1; Nov 2005) or callable (PHP 5.4; Mar 2012). There was no common ancestor object (like in some other programming languages like C#) in PHP object/type model. What you had to specify was stdClass

    function abc(stdClass $obj) {
        return;
    }
    

    As of PHP 7.2 (Nov 2017) it’s possible to use object type hint exactly as you guessed in your question:

    function abc(object $obj) {
        return;
    }
    

    Cf. Type declarations in the PHP manual.

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

Sidebar

Related Questions

Is it like... var obj = new Object(); obj.function1 = function(){ //code } or
Here is an object: var obj = new function(){ this.prop = {}; } and
I have a script which creates a user-defined object like this: obj = new
// // To Throw void PrintType(object obj) { if(obj == null) { throw new
private void btnSend_Click(object sender, RoutedEventArgs e) { Button obj=(Button)sender; obj.Content=Cancel; SendImage send = new
I need to initialize my object like below: var obj = new EduBranch {
I Have an object with a set of parameters like: var obj = new
I'm trying to call a function from this: var _coll = [new Obj('a', somefunction)];
We normally create objects using the new keyword, like: Object obj = new Object();
Is it possible for the following line to return null? MyClass obj = new

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.