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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:20:37+00:00 2026-05-22T22:20:37+00:00

anyone has an idea how to create a class in PHP then when called

  • 0

anyone has an idea how to create a class in PHP then when called loads an array for example

$cart = new Cart(); //where Cart is the Class Name
print_R($cart); //print the constructor

At this Point I want something like this array

$cart = ([id] => ,[currency]=> ,[country]=> )

How anyone guide me how can I set up a constructor for this call,even if the properties are empty , I just want the key values for the array so that I can set its values like below

$cart->id = 1;
$cart->currency = EUR;
$cart->country= DE;

in this way it would be much easier to call in a new CART in this example… and then manipulate the class properties in order to save to database etc

  • 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-05-22T22:20:38+00:00Added an answer on May 22, 2026 at 10:20 pm
    class Cart
    {
        private $id, $currency, $country;
    
        public function __construct($id = 1, $currency = 'EUR', $country = 'DE')
        {
            $this->id = $id;
            $this->currency = $currency;
            $this->country = $country;
        }
    }
    

    If you pass no arguments to your constructor, it’ll inherit the defaults in the function argument spec.

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

Sidebar

Related Questions

I wonder if anyone has an idea how you have to transform an image
Has anyone an idea how the type inference problem E > hd (cons 1
Has anyone an idea how pipebytes.com works ? I need to implement similar system
Has anyone got any idea why the menu is rendering below the rotating images
anyone has a working example of a TTThumbsViewController used with files included in the
Does anyone has the code to a full working example of slartoolkit ( http://slartoolkit.codeplex.com/
I want to implement a string class which has an option to create the
Anyone has a ready implementation of the Reverse Breadth First traversal algorithm in C#?
Does anyone has a good solution for a C# version of the C++ __FUNCTION__
Does anyone has sources for visual explanations of algorithms (or maths) that is even

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.