Jump to content

Class inheretance clarification.


Perad

Recommended Posts

I am extending a previous class of mine, all i need to change in this class is a single variable.

 

This is what i have.

 

class Profile {
public function EditProfile() {		
$userid = $_SESSION['user_id'];
...
...
}
}

class EditMembers extends Profile {
protected function EditProfile() {
$userid = $_POST['editmember'];
}
}

 

What i want to know is if I can simply change this one variable without affecting the rest of the function. Would EditProfile() be whiped in the child class or would only this one thing change?

Link to comment
https://forums.phpfreaks.com/topic/50464-class-inheretance-clarification/
Share on other sites

What are you a re doing is called method overriding.  The entire method of the derived class (the child class) will always be run if it is called from child instance.  Why not just pass the variable in as a parameter?

 

<?php
class Profile {
public function EditProfile($userid) {		
...
...
}
}
?>

 

Best,

 

Patrick

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.