Jump to content

Simple explanation needed for this


rondog

Recommended Posts

I come from an actionscripting background so I am curious as to why this does not work in PHP?

 

<?php
$test = "testvar";

function runMe()
{
echo $test; //--- returns an undefined variable error
}

runMe();
?>

 

How would I go about making $test available to the runMe() method without passing it into the method itself?

Link to comment
https://forums.phpfreaks.com/topic/205793-simple-explanation-needed-for-this/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.