• 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)
  • 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

    (@jbbrwcky)

    Thanks firas!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘variable scope’ is closed to new replies.