Hi Leonard, Try this:
<? php; class first { var $total; function first($age, $name) { $this->total = $age.$name; } } //main script $obj = new first(35, "chris"); print $obj->total; ?> The problem with what you were doing is that when you were instantiating the class, with the way you have set this up, you need to pass arguments because when you create a new instance of the class the function with the same name as the class is called and, in this case, it is expecting arguments. Another example of a class set-up would be: <? php; class first { function first() { //do something like connect to a database or set some variables } function second($age, $name) { /*here you could look something up in the db or do something else and then return what ever you like*/ return $age.$name; } } //main script $obj = new first(); $test = $obj->second(35, "chris"); print $test; ?> At 2:27 PM -0500 on 2/3/03, Leonard Burton 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 -- Daniel Leighton Chief Technology Officer Webolution http://www.webolution.com This email may contain material that is confidential and privileged for the sole use of the intended recipient. Any review, reliance or distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php