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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:52:19+00:00 2026-06-11T14:52:19+00:00

i have something like this: class foo { //code } $var = new foo();

  • 0

i have something like this:

class foo
{
   //code
}

$var = new foo();
$var->newVariable = 1; // create foo->newVariable
$var->otherVariable = "hello, im a variable";  //create foo->otherVariable

i can get in class foo a list of all variables defined outside by user (newVariable, otherVariable,etc)? Like this:

class foo
{
   public function getUserDefined()
   {
      // code

   }
}

$var = new foo();
$var->newVariable = 1; // create foo->newVariable
$var->otherVariable = "hello, im a variable";  //create foo->otherVariable
var_dump($var->getUserDefined()); // returns array ("newVariable","otherVariable");

Thanks!.

  • 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-11T14:52:20+00:00Added an answer on June 11, 2026 at 2:52 pm

    Yes, using get_object_vars() and get_class_vars():

    class A {
    var $hello = 'world';
    }
    $a = new A();
    $a->another = 'variable';
    echo var_dump(get_object_vars($a));
    echo '<hr />';
    // Then, you can strip off default properties using get_class_vars('A');
    $b = get_object_vars($a);
    $c = get_class_vars('A');
    foreach ($b as $key => $value) {
        if (!array_key_exists($key,$c)) echo $key . ' => ' . $value . '<br />';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that looks something like this: public class Foo<T> : ObservableCollection<T> {
So I have two classes like this: class foo { /* code here */
I have a code like this: class Foo() { time_to_play = 0 class Bar()
Suppose you have something like this: class intlist: def __init__(self,l = []): self.l =
Suppose I have something like this: class A { public B mem; public int
So let's say you have something like this: Class Person: height = 6' 0
I have something like this set up: class CategoryPage (webapp.RequestHandler): def get(self): ** DO
Okay, I have something like this in C++: class MyClass{ private: int someVariable; int
I have something like this in my Spring Application: public class Book{ public Book(){
I have something like this currently: <div class = className style = position: absolute;

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.