When you name a function in the class with the same name as the class
itself, this function gets automatically executed upon defining the
object (class). this is called `constructor'.

in your very case, this is the function first, which requires two
parameters to be passed to it. You need to create the instance (define)
your class with already passing parameters to it. Like this:

$obj = new First($par1, $par2);

The next, you don't need to call $obj->first(..., ...); once again, as
you just did it one line above.

-- 
Maxim Maletsky
[EMAIL PROTECTED]


On Mon, 3 Feb 2003 14:27:36 -0500 "Leonard Burton" <[EMAIL PROTECTED]> wrote:

> Greetings,
> 
>       I am trying to figure out using classes.  I have read and read and read
> about them but still cannot figure them new fangled things out.  Could
> someone please alter this snippet just a bit so it would be a correct test
> script with a call to it?
> 
> When  I run the script I get this in my browser <<
> 
> Warning: Missing argument 1 for first() in /usr/~~~~~~~~~~~~~index.php on
> line 8
> Warning: Missing argument 2 for first() in /usr/~~~~~~~~~~~~~~~~~/index.php
> on line 8
> 35chris
> >>
> 
> As you see it does print the output.  What am I doing wrong?
> 
> Thanks,
> 
> Leonard
> [EMAIL PROTECTED]
> 
> 
> 
> <? php;
> class first
> {
>         var $age;
>         var $name;
> 
>         function first($age, $name)
>         {
>                 return $age.$name;
>         }
> }
> 
> //main script
> $first = new first;
> $test=$first->first(35, "chris");
> 
> print $test;
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to