With php5, I'm trying to create an object that has a property that is
another object.  First I have this class:

<?php
class Address {

    public $address1;
    public $address2;
    public $city;
    public $state;
    public $zip;

}
?>

Then I have another class:

<?php
require_once('model/Address.class.php');
class User {
    public $name;
    public $address = new Address();
}
?>

Then if I try to use the user object like this:

<?php
require_once('model/User.class.php');

$user = new User();
$user->name = 'Paul Barry';
$user->address->city = 'Washington';

?>
<?= $user->name ?> lives in <?= $user->address->city ?>

I get this error:

Parse error: syntax error, unexpected T_NEW in /app/model/User.class.php on
line 5

What am I doing wrong?

Reply via email to