Title: Variables scope
Last modified: August 19, 2016

---

# Variables scope

 *  [eastsidedev](https://wordpress.org/support/users/eastsidedev/)
 * (@eastsidedev)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/variables-scope/)
 * I am using one of the pages, to display a list. I have the following in the page:
 *     ```
       <? php
       include_once "myFunctions.php";
       include_once "myDeclarations.php";
       displayText();
       ?>
   
       Inside myFunctions.php, I have the following function:
   
       function displayText() {
       GLOBAL $textToDisplay;
       echo "Testing WordPress";
       echo $textToDisplay;
       }
       ```
   
 * Inside myDeclarations.php, I have the following:
 * $textToDisplay = “This is a test”;
 * When I go to that page, it only displays: Testing WordPress. The variable $textToDisplay
   is not passed. It seems as if the include file that has the function in it, is
   recognized, but the variable in the other file, is not. How do I deal with this
   scope issue in WordPress?

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/variables-scope/#post-1563343)
 * Have you tried declaring $textToDisplay as a GLOBAL inside myDeclarations.php?

Viewing 1 replies (of 1 total)

The topic ‘Variables scope’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [15 years, 10 months ago](https://wordpress.org/support/topic/variables-scope/#post-1563343)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
