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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:36:53+00:00 2026-06-08T20:36:53+00:00

It know it can be done with get_class($variable) . The problem is that my

  • 0

It know it can be done with get_class($variable).
The problem is that my $object is actually a string containing the variable name.

so:

$object = new MyClass();

$var = '$object';

$class = get_class($var); // obviously fails

I can’t use get_class($object), because I don’t have direct access to that variable (I’m producing the $var string from parsing a PHP expression using token_get_all())

I tried using eval(sprintf('return get_class(%s);', $var)), but it doesn’t work because the variable appear undefined from eval’s scope 🙁

Is there a way to do this?

I need to know the class in order to pass it to ReflectionMethod, so I can get information about a method (the next element in the PHP expression).


NVM: I’m pretty sure it is not possible. Sorry for asking:)

  • 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-08T20:36:57+00:00Added an answer on June 8, 2026 at 8:36 pm

    you can do

    $var = new $object();

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

Sidebar

Related Questions

I have a query that I know can be done using a subselect, but
I know it can't be done since using var can only be done for
Example: before: text_before_specific_character(specific_character)text_to_be_deleted after: text_before_specific_character I know that it can be done with sed
I know that this can be easily done by using if(i%5 == 0 OR
This is something I know can be done somehow , because I've done it
I know this can be done and i have seen it done using some
I know it can be done but am having issues getting it to work.
Can CUDA be used to generate OpenGL textures? I know it can be done
I'd like to obscure strings at compile time. I know it can be done
As far as I know, everything done in XAML can be done in C#.

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.