Tell file in sub drawer it is included bei file in parent folder

Hi,

lets say I have a file index.php in the root of my php project. This file looks like

require_once("config.php");
include_once("./pages/".$_GET['page']); 

Let's assume in the config.php I  do something like

$dbConnection = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8") );
$dbConnection->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );

Now I want to access this dbConnection in a pages/xy.php file

This works, but of course I got an unresolved variable warning from the inspector because the inspector could not know, that this file is included by a file in the parent drawer which included the config.php.

Is there any possibility to tell the xy.php file where it can find the $dbConnection to get rid of this warning?

Regards

Claus

1 comment
Comment actions Permalink

No, currently there's no such a way, unfortunately. You can disable the inspection for the statement, or do "include_once" again in the file.

0

Please sign in to leave a comment.