Question: Is there a way to create/define a variable available to all php files(like superglobals)

> 
> Example:
> 
> 
> i define a variable in **file1.php** `$car = ferrari`
> 
> 
> then in **file2.php** i write `echo $car;`
> 
> 
> then it will output `ferrari`
> 
> 
> 

how can i define a variable in file1.php and access it in file2.php

**EDIT:**

The answers is good, but do is there another alternative?because i will have multiple php files in multiple directories, do i have to create its own php file for each directory?if thats the only way, then i'll do it.

Answer: 
Create one constant file and include it in file in where you want to access those constants.

Include file as

```
include 'file_path';

```
You can use `SESSION` or `include` concept.

1) By using `SESSION`

**file1.php**

```
session_start();
$_SESSION['car'] = 'ferrari';

```

**file2.php**

```
session_start();
echo $_SESSION['car'];  //Result: ferrari

```

2) By using `include`

**file2.php**

```
include 'file1.php';
echo $car //Result: ferrari

```