I have a PHP website which has two core php files ci_controller.php
and my_controller.php
and a number of controller php files.
My_Controller
class extends CI_Controller
.
The other contoroller PHP classes extend My_Controller
.
I was wanting to change the website so that some of the thing My_Controller
class will only occur for some of the classes which extended. i.e. depending on which class extended My_Controller
do x.
I was wondering if it is possible to use the parent/child relationship (or see which files extend a class) to create an if/exception so that some of the My_Controller
parts on run for certain PHPs?
For example if a three classes;
- classA, classB and classC.
- classA and classB both extend classC (i.e class classA extends classC)
In this example I want to have a line in classC which does the following pseudo code:
if (extended by classA)
{//do something}
else if (extended by classB)
{//do something else}
NOTE: Two similar questions on stackoverflow are:
However they do not solve my problem, but maybe helpful for those looking for a similar solution