# Accessing variables within includes?

**URL:** <https://forum.kirupa.com/t/accessing-variables-within-includes/216756>\
**Category:** programming\
**Created:** [February 20, 2007, 10:44am UTC](https://forum.kirupa.com/t/accessing-variables-within-includes/216756 "2007-02-20T10:44:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![J\_S](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@J\_S](https://forum.kirupa.com/u/J_S)\
**Post date:** [February 20, 2007, 10:44am UTC](https://forum.kirupa.com/t/accessing-variables-within-includes/216756/1 "2007-02-20T10:44:00Z")

</div>

I’m quite new to PHP and need some help. I’ve got **index.php** which looks like this:

```php

<?php
$sectionname = "index";
include "header.php";
?>

```

Then in **header.php** i’ve got:

```php

<?php 
echo($sectionname);
?>

```

index.php displays blank (ie doesn’t echo $sectionname). How can i make a variable defined in index.php available in header.php?
