So i have this kind of struct function in main class
function __construct(){
    $this->conf = $GLOBALS['conf'];
    $this->dbi = new dbinfo;
    $this->modOpt = new modOptions;
    $this->lang = new language;
    /** Connect DB extended Class **/
    parent::__construct($GLOBALS['connect']);
}
where i define classes, but this classes is into library file which is included at the start of file except one, which is included when post request will appear like this:
if (isset($_POST['delGroup']) && isset($_SESSION['content_viewer']) && $_SESSION['content_viewer']['code'] >= 1){   
    include_once(realpath(dirname(__FILE__) . '/../..')."/mod/dbinfo/proc.php");
}
so i want add check into my construct function for dbinfo class like this
function __construct(){
    $this->conf = $GLOBALS['conf'];
    if (isset(new dbinfo))
        $this->dbi = new dbinfo;
    $this->modOpt = new modOptions;
    $this->lang = new language;
    /** Connect DB extended Class **/
    parent::__construct($GLOBALS['connect']);
}
but this method with if isset does not works, please show me correct way how to check if class exists into file. thanks
Try using, class_exists()  http://php.net/manual/en/function.class-exists.php
In your case, looking for dbinfo class do this:
      if(class_exists('dbinfo')){
          //do something
If your class has a namespace, include the ful namespaced classname.
class_exists('class_name',false); 
Set false to true if the function should try too load the class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With