0

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
2
Contributors
2
Replies
24
Views
4 Years
Discussion Span
Last Post by arifkutty
0

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

Edited by phorce

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.