Title: variable scope
Last modified: August 18, 2016

---

# variable scope

 *  [jbbrwcky](https://wordpress.org/support/users/jbbrwcky/)
 * (@jbbrwcky)
 * [20 years, 11 months ago](https://wordpress.org/support/topic/variable-scope/)
 * I’m working in the index.php which calls various other bits in the theme. At 
   the top, to randomize I declare…
 * `srand((double)microtime()*1000000); 
    $randval = rand(0,1);
 * … inside `<?php ?>` section. If I want to use it later on in the same file, I
   can still call `$randvall` without having to declare srand again right?
 * Jbbrwcky

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Firas](https://wordpress.org/support/users/firas/)
 * (@firas)
 * [20 years, 11 months ago](https://wordpress.org/support/topic/variable-scope/#post-229638)
 * As long as you’re not within a function or something like that, sure. If you’re
   curious about what the value is of $randval somewhere just do `<?php var_dump(
   $randval); ?>`. If it turns out empty, do `<?php global $randval; ?>` before 
   you use it.
 *  Thread Starter [jbbrwcky](https://wordpress.org/support/users/jbbrwcky/)
 * (@jbbrwcky)
 * [20 years, 11 months ago](https://wordpress.org/support/topic/variable-scope/#post-230163)
 * Thanks firas!

Viewing 2 replies - 1 through 2 (of 2 total)

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

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [jbbrwcky](https://wordpress.org/support/users/jbbrwcky/)
 * Last activity: [20 years, 11 months ago](https://wordpress.org/support/topic/variable-scope/#post-230163)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
