[PHP] Re: oop problems code

2003-09-18 Thread Greg Beaver
Orlando,

Displayer also inherits the constructor from Employee, so you must 
define function Displayer() to prevent the notices.

I don't think you want to extend from Employee with Displayer - it 
should accept an Employee object, and display the information, perhaps.

Regards,
Greg
Orlando Pozo wrote:

Hello, mailing list, I have problem with this oop code:

?

class Person {
  var $name, $address, $age;
  function Person($name, $address, $age) {
$this-name = $name;
$this-address = $address;
$this-age = $age;
  }
}
Class Employee extends Person {
  var $position, $salary;
  function Employee($name, $address, $age, $position, $salary) {
$this-Person($name, $address, $age);
$this-position = $position;
$this-salary = $salary;
  }
}
Class Displayer extends Employee {
 function DisplayEmployee() {
  echo Name:  . $this-name . br;
  echo Address:  . $this-address . br;
  echo Age:  . $this-age . br;
  echo Position:  . $this-position . br;
  echo Salary:  . $this-salary . br;
 }
}
$obj1 = new Employee(Orlando J Pozo P,Calle 75 AV 
9B-10,20,Computer Engineer,$2000);
$obj2 = new Displayer;
$obj2-DisplayEmployee();

?

-- 

the output of it is:

Warning: Missing argument 1 for employee() in 
C:\htdocs\ojpp\poo\3\practica\Copy of 18.php on line 16

Warning: Missing argument 2 for employee() in 
C:\htdocs\ojpp\poo\3\practica\Copy of 18.php on line 16

Warning: Missing argument 3 for employee() in 
C:\htdocs\ojpp\poo\3\practica\Copy of 18.php on line 16

Warning: Missing argument 4 for employee() in 
C:\htdocs\ojpp\poo\3\practica\Copy of 18.php on line 16

Warning: Missing argument 5 for employee() in 
C:\htdocs\ojpp\poo\3\practica\Copy of 18.php on line 16
Name: Address: Age: Position: Salary:

-- 

  I don't know what happen in this code, because, the last inheritance 
(Displayer Class) that I made, it is inherited the properties and 
methods of the Employee Class, and as Employee Class is also inherited 
the functionality of the parent class, the Displayer Class would be 
inherit this functionality, too.

  thanks if any could help me, regards, bye.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: OOP Problems

2001-07-14 Thread u007

hie..
it's simply u did not declare ur class variable...

class ctest
{
var $owner;

function ctest($owner)
{
$this-owner = $owner;
}

function foo()
{
echo test!br;
}
}

hope it works :)
regards,

James

Andrew Kirilenko wrote:

 Hello!

 I have following problem:

 ?
 $container = new ccontainer();
 $container-init();
 $container-test1-foo();
 $container-test2-foo();
 $container-test2-owner-test1-foo();
 $container-test1-owner-test2-foo();

 class ccontainer
 {
 function ccontainer()
 {
 }

 function init()
 {
 $this-test1 = new ctest($this);
 $this-test2 = new ctest($this);
 }
 }

 class ctest
 {
 function ctest($owner)
 {
 $this-owner = $owner;
 }

 function foo()
 {
 echo test!br;
 }
 }
 ?

 Output of this script is:
 ---
 test!
 test!
 test!
 Fatal error: Call to a member function on a non-object in c:\www\a.php on
 line 8
 ---

 How to solve this problem???

 Best regards,
 Andrew Kirilenko,
 Senior Programmer / System Administrator,
 Internet Service.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: OOP Problems

2001-07-14 Thread teo

Hi u007!
On Sun, 15 Jul 2001, u007 wrote:

 hie..
 it's simply u did not declare ur class variable...
 
well, actually you don't have to declare them, you can add members as you go
(as opposed to C++ for example)

 class ctest
 {
 var $owner;
 
 function ctest($owner)
 {
 $this-owner = $owner;
 }
 
 function foo()
 {
 echo test!br;
 }
 }
 
 hope it works :)
 regards,
 
 James
 
 Andrew Kirilenko wrote:
 
  Hello!
 
  I have following problem:
 
  ?
  $container = new ccontainer();
  $container-init();
  $container-test1-foo();
  $container-test2-foo();
  $container-test2-owner-test1-foo();
  $container-test1-owner-test2-foo();
 
  class ccontainer
  {
  function ccontainer()
  {
  }
 
  function init()
  {
  $this-test1 = new ctest($this);
  $this-test2 = new ctest($this);
  }
  }
 
  class ctest
  {
  function ctest($owner)
  {
  $this-owner = $owner;
  }
 
  function foo()
  {
  echo test!br;
  }
  }
  ?
 
  Output of this script is:
  ---
  test!
  test!
  test!
  Fatal error: Call to a member function on a non-object in c:\www\a.php on
  line 8
  ---
 
  How to solve this problem???
 
  Best regards,
  Andrew Kirilenko,
  Senior Programmer / System Administrator,
  Internet Service.
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
-- teodor

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: OOP Problems

2001-07-14 Thread James Tan

oh,

i didn't realise how php is as flexible as vb :)

yeah.. ops, missed out the owner-test1 does not exist :)

thanx for tips :)

[EMAIL PROTECTED] wrote:

 Hi u007!
 On Sun, 15 Jul 2001, u007 wrote:

  hie..
  it's simply u did not declare ur class variable...
 
 well, actually you don't have to declare them, you can add members as you go
 (as opposed to C++ for example)

  class ctest
  {
  var $owner;
 
  function ctest($owner)
  {
  $this-owner = $owner;
  }
 
  function foo()
  {
  echo test!br;
  }
  }
 
  hope it works :)
  regards,
 
  James
 
  Andrew Kirilenko wrote:
 
   Hello!
  
   I have following problem:
  
   ?
   $container = new ccontainer();
   $container-init();
   $container-test1-foo();
   $container-test2-foo();
   $container-test2-owner-test1-foo();
   $container-test1-owner-test2-foo();
  
   class ccontainer
   {
   function ccontainer()
   {
   }
  
   function init()
   {
   $this-test1 = new ctest($this);
   $this-test2 = new ctest($this);
   }
   }
  
   class ctest
   {
   function ctest($owner)
   {
   $this-owner = $owner;
   }
  
   function foo()
   {
   echo test!br;
   }
   }
   ?
  
   Output of this script is:
   ---
   test!
   test!
   test!
   Fatal error: Call to a member function on a non-object in c:\www\a.php on
   line 8
   ---
  
   How to solve this problem???
  
   Best regards,
   Andrew Kirilenko,
   Senior Programmer / System Administrator,
   Internet Service.
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 -- teodor


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]