...

View Full Version : it doesnt recognize OOP??



ausgezeichnete
11-02-2007, 10:23 PM
<?php
class Cat{
var $legs=4;
}
$tiddles=new Cat();
echo $tiddles->legs;
?>

it gives me legs;
am using WAMP version 1.7.2

Mwnciau
11-02-2007, 10:59 PM
If you are using PHP5 you need to replace var with public (or private or protected)


<?php
class Cat{
public $legs=4;
}
$tiddles=new Cat();
echo $tiddles->legs;
?>

ausgezeichnete
11-03-2007, 06:42 PM
thnxx it works now

firepages
11-04-2007, 01:49 AM
glad its working now, but for the record , `var` works fine in PHP5 though ideally you will be using public/private etc

marek_mar
11-04-2007, 01:58 AM
Actually var is supposed to become an alias of public in PHP6.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum