Results 1 to 18 of 18
Jul 19, 2012, 22:05 #1
- Join Date
- Jul 2012
- 0 Post(s)
- 0 Thread(s)
OOP PHP Is it possible to call on a function from other classes
I am a bit new to OOP although I have been coding procedural PHP for years.
Here is what I am trying to figure out.
Say I have several classes and I want to call on a function from one of those classes inside a function in the other classes. What is the best way to do this? Do I have to extend them all from the first one, that seems like it would get really confusing if I have 8-10 different classes.
Below is a scenario of something similar to what I would like to do.
public function setHistory()
$sql = "insert into history (some columns here) values (some values here)";
$result = mysql_query($sql);
public function updateTask()
$result = mysql_query("update task set subject = "testing" where task_id = $this->task_id ");
$setHistory(); //TRYING TO CALL FUNCTION FROM OTHER CLASS
public function updateContact()
$result = mysql_query("update contact set first_name = "John" where contact_id = $this->contact_id ");
$setHistory(); //AGAIN IM TRYING TO CALL FUNCTION FROM OTHER CLASS
Any help would be very much appreciated.