Extending Class, The right way? (BASIC) |
[eluser]solid9[/eluser]
How to extend class the right way? And how to call a method in the parent class inside the child class? <b>Show me sample, using the format below,</b> parent: person.php (parent class) child: employee.php (child class) Thanks in advanced.
[eluser]Andy78[/eluser]
I'm sure you just call the method in the child class exactly as you would in the parent class.
[eluser]solid9[/eluser]
@andy78 can you show me sample. How about I have two classes in two separate files? Thanks in advanced.
[eluser]Andy78[/eluser]
Any php oops tutorial for beginners will help you with this. To call a method in the parent class inside the child class you would simply use $this->some-method(); exactly as you would in the parent class since all methods in the parent class are also methods of the child class. Get it? Code: <?php
[eluser]boltsabre[/eluser]
And if you're child class has the same method name as the parent, it will override the parent method (by default, I'm pretty sure that there is a way to get around this but it escapes me currently). Think it's parentClassName::methodName This is a good intro tutorial http://www.killerphp.com/tutorials/objec.../index.php
[eluser]soprabaixar1[/eluser]
See: http://ellislab.com/forums/viewthread/204977/ |
Welcome Guest, Not a member yet? Register Sign In |