Is it possible to include a file using PHP but NOT the other files that it includes

OK I have accepted this is not possible, so I am pursuing another route - to extract the variables I want from wp-config without including it.

I have the following script to do this but there are some issues with single / double quotes which I am exploring in a separate post How do I format preg_match() to identify single quote or double quote when matching for those who want to follow.

Script so far to extract Wordpress database credentials - works with vars enclosed in single quotes but not double quotes

<?php
$file_name = 'wp-config.php';
$value = file_get_contents($file_name);

preg_match('/define.*DB_NAME.*\'(.*)\'/', $value, $m);
$dbname = $m[1];

preg_match('/define.*DB_USER.*\'(.*)\'/', $value, $m);
$dbuser = $m[1];

preg_match('/define.*DB_PASSWORD.*\'(.*)\'/', $value, $m);
$dbpass = $m[1];

preg_match('/define.*DB_HOST.*\'(.*)\'/', $value, $m);
$dbhost = $m[1];

preg_match('/define.*DB_CHARSET.*\'(.*)\'/', $value, $m);
$dbcharset = $m[1];

preg_match('/define.*DB_COLLATE.*\'(.*)\'/', $value, $m);
$dbcollate = $m[1];

echo $dbname, $dbuser, $dbpass, $dbhost, $dbcharset, $dbcollate;
?>