How to load a php file into a variable in php?

In this post, we will show you how to use one PHP file’s variables in PHP.

1. Code:

soltuts.php
<?php 
return array(
  'SOL' => 'Soltuts.com',
  'SNIP' => 'Snipcode'
);
loadFile.php
 <?php
$filePath = "soltuts.php";
$data = include $filePath;
print_r($data);
?> 

2. Example:

Input:

file: soltuts.php

Output:

Array ( [SOL] => Soltuts.com [SNIP] => Snipcode );