PHP Passing variables between two files -


i have piece of code:

foreach (glob('mov/$context.mov') $filename){      $thedata = file_get_contents($filename) or die("unable retrieve file data"); } 

is correct way add variable within glob? $context

also, in new file, want replace word $context, write

$context = "word"; // adds word glob function when script included in different file. 

you should use double-quotes in first parameter of glob function.

glob("mov/$context.mov") 

or, if want, use brackets

glob("mov/{$context}.mov") 

in way variable name replaced value.

edit:
other question:
the script glob function can executed multiple times changing value of $context variable before script inclusion. example:

$context = "word"; include("test.php");  $context = "foo"; include("test.php"); 

Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -