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

  • Home
  • SEARCH
  • 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 8037853
In Process

The Archive Base Latest Questions

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

Would be possible to check statically (meaning without creating an instance) if a string

  • 0

Would be possible to check statically (meaning without creating an instance) if a string containing a FQCN like $fqcn:

function checkCreatingInstance($fqcn)
{
    // Create a new instance
    $instance = new $fqcn;

    return ($instance instanceof 'MyNamespace\Entity\SendMessage');
}

function checkStatically($fqcn)
{
    /* TODO */
}

$fqcn = 'MyNamespace\Entity\SendSmallTextMessage';
var_dump(checkCreatingInstance($fqcn)); // true

Is of a given type? An example hierarchy:

namespace MyNamespace\Entity;

class SendMessage { /* Stuff */ }

namespace MyNamespace\Entity;

class SendNewsletter extends SendMessage { /* Stuff */ }

namespace MyNamespace\Entity;

class SendSmallTextMessage extends SendMessage { /* Stuff */ }
  • 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:03:03+00:00Added an answer on June 5, 2026 at 3:03 am

    Yes. is_a() will do it, if you pass TRUE as the third argument.

    Example

    The advantage of this is that you can write your function so it accepts and object or a string and it will work either way, you don’t have to have two functions for a static and instantiated check:

    function checkIsChildOf ($objOrFQCN, $parent)
    {
        return is_a($objOrFQCN, $parent, TRUE);
    }
    

    Yet another example of the PHP manual being poor – this behaviour is documented in the manual, so far as I can tell but I have no clue why you didn’t see it, so the manual is just poor to not make it visible.

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

Sidebar

Related Questions

I would like to know if it's possible to check if URL is indexed
This seems like it would be possible. protected SameObjectTypeAsInputParameterObjectType GetAValue(someObject,TypeOrReturnObjectYouWant){ //check to see if
I would like to know if it's possible to check the current time of
Would be possible to check if an association exists before issuing a query in
I wonder if it would be possible for me to employ a recursive function
I would like to know if it would be possible to replicate the effect
Would it be possible to add a new operator to the String class that
In a setup like this is it possible to check the cumulative status of
is it possible to check if pdf is password protected using ghostscript? what would
<?php echo $Variable; ?> **// I would like to check if the variable is

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.