Title: PHP Include And Variable Issue
Last modified: August 20, 2016

---

# PHP Include And Variable Issue

 *  [haydenm92](https://wordpress.org/support/users/haydenm92/)
 * (@haydenm92)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/php-include-and-variable-issue/)
 * I’m storing a value into a variable I’ve created called $mov_sub. I’m using the
   Exec-PHP plugin to put PHP into posts. This is the PHP I’ve got in my post:
 * `<?php mov_sub = "123"; ?>`
 * Then I’ve got a file included using PHP in my header.php file. The source code
   for the included file is along the lines of:
 *     ```
       <?php
   
       if(is_single( array( 1079, 1088 ) ) )
   
       if(isset($mov_sub)) {
       	$sid = "&sid=$mov_sub";
       }
       else {
       	$sid = "&sid=";
       }
       	echo "$sid";
       }
       ?>
       ```
   
 * It’s only echoing &sid, not &sid=123 like it should be doing. I tested this outside
   of WordPress and it works fine. I thought maybe it wasn’t working because WordPress
   uses a function to create the post content called the_content() and I think functions
   only allow local variables unless you declare a global variable. So I edited 
   the post-template.php file in wp-includes where the_content() function is located
   and added:
 * `global $mov_sub;`
 * but that didn’t work either. I’m really new to PHP and have been struggling with
   this for a few hours now. Does anyone know why it’s not working?

The topic ‘PHP Include And Variable Issue’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [variable](https://wordpress.org/support/topic-tag/variable/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [haydenm92](https://wordpress.org/support/users/haydenm92/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/php-include-and-variable-issue/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
