Thread: OOP with PHP
View Single Post
Old 08-01-2002, 02:09 PM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,486
sde is on a distinguished road
yes, you can use a constructor =)

I think it's even proper to define variables in the class first, but not necessary.

From what i've researched, there is no distinction between public and private members of the class. They all seem to be public.

Here's how the constructor would work.
PHP Code:
<?
class user
{    
      function 
user
     
{
          
$this->name=$username;
     }
}

$me = new user("mike");
$you = new user("joe schmoe");



echo 
"my name is " $me->name;
echo 
"your name is " $you->name;

?>
currently i'm working on a new look and feel for the site as well as new forums .. i will create a new num after this change.
sde is offline   Reply With Quote