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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:24:26+00:00 2026-06-14T10:24:26+00:00

Thanks in advance for help and direction. I am finally making the switch from

  • 0

Thanks in advance for help and direction. I am finally making the switch from linear programming to OOP. I am working on my first class ever and I could use a little direction. My first class is a gallery with the following properties

class Gallery
    {
        //Gallery Name
        public $galleryID;
        public $galleryName;

        //Client Name
        public $clientName;

        //Gallery Options
        public $bg_color;
        public $albumAgreement;
        public $maxChanges;
        public $sharing_on;

        //Revisions
        public $revisions;
}

My out put thus looks like:

Gallery Object
(
    [galleryID] => 
    [galleryName] => 
    [clientName] => 
    [bg_color] => 
    [albumAgreement] => 
    [maxChanges] => 
    [sharing_on] => 
    [revisions] => 
)

My next step is I would like to make ‘revisions’ an object as well so that my output would look like

Gallery Object
(
    [galleryID] => 
    [galleryName] => 
    [clientName] => 
    [bg_color] => 
    [albumAgreement] => 
    [maxChanges] => 
    [sharing_on] => 
    [revisions] => Revisions Object (
        [revisionID] =>
        [revisionName] =>
    )
)

What direction do I go for something like this and what might the class look like?

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-14T10:24:28+00:00Added an answer on June 14, 2026 at 10:24 am

    The good thing is PHP is dynamically typed, so your code remains pretty much the same. When you initialize revisions, just initialize it to be an instance of Revisions object, like this

    $gallery = new Gallery();
    $gallery->revisions = new Revisions()  // assuming you have defined the Revisions class
    

    As for what the class should look like, based on your var_dump, something like this:

    class Revisions {
      public $revisionID;
      public $revisionName;
    
      public function __construct($id, $name) {
         $this->revisionID = $id;
         $this->revisionName = $name;
      }
    
      // if required, define a default constructor as well that does not take any parameters
    
    }
    

    Since what revisions does is not entirely clear from your question, you might want to make a Revision object instead of Revisions (not the plural), and then have $gallery->revisions be an array of Revision.

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

Sidebar

Related Questions

First off, thanks in advance for your help. This issue is driving me nuts.
newbie here, so thanks in advance for help! I have a Wordpress site with
Thanks in advance for your help. I have a need within an application to
Thanks in advance for any help you can provide on this issue! I manage
Thanks in advance for your help experts. I want to be able to copy
Hi thanks in advance for your help. I'm just getting started learning Python and
I am using c# .net. Thanks in advance for any help. I have searched
I need help in jquery. Thanks in advance. I am using autocomplete function of
Thanks for any help in advance, I can't wrap my SQL skills around this
Greetings and thank you in advance for the help. I created a user control

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.