class Jcart {

public $config     = array();
private $items     = array();
private $names     = array();
private $prices    = array();
private $qtys      = array();
private $urls      = array();
private $subtotal  = 0;
private $itemCount = 0;

can any body please explain what the meaning of above code. in the first line its says class Jcart in my other index.php file, the thing is i am learning php and so i downloaded this code and try to understand it but i got stuck in these lines. and i dont understand why he wrote it that way, please explain

Recommended Answers

All 2 Replies

This piece of code is a Class, which forms part of the OO techniques built into PHP. OO in itself is a very large subject, so, it would be impossible for me to write a massive post explaining it all, but, you can try the following links:

PHP Class
OOP

Within the code we have this:

public $config = array(); The public in this example tells the interpereter what the restrictions are of accessing this member (where the member is $config) and it's just assigning an array to this value. I assume you know what Arrays are? If not, there are tutorials online which will help to explain this.

IMO I think you should stay away from classes, and object-oriented programming until you know the basics of PHP or language syntax, logic and structure. Try not to download code, that you do not understand. :)

Hope this helps

Thanks for the reply, and yah i did not relise its oop code, i am new and learning php, when i see this code i thought i learn nothing, thanks for the reply

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.