Do some servers support classes and others don't?

I wrote a shopping cart on one server and copy/pasted in onto another server and i get the following error:

Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in .../classcart/ShoppingCart.php on line 7

This is how the code starts for the ShoppingCart.php page. The first class is named ShoppingCart, followed by many functions and other classes and finally ending with a "}".

class ShoppingCart
{
   private $DBConnect = "";
   private $DBName = "";
   private $TableName = "" ;
   private $Orders = array();
   private $OrderTable = array();

I don't understand why I'm getting an error that it doesn't recognize the class as a class. Any ideas what's going on?

What version of php are you using? I believe if it is below 5 then you'll have to replace all instances of private with public.

What version of php are you using? I believe if it is below 5 then you'll have to replace all instances of private with public.

I don't know which version it is, but I changed all the instances of private to public and I get the same error. Any ideas?

Sorry, I only had this problem once a long time ago. Seems like versions before php5 don't support private/public so change the instances to var.

I don't know which version it is.

Create a php info page.

<?php phpinfo(); ?>

This will output every detail about your server config.

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.