faqts : Computers : Programming : Languages : PHP : kms : General

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 11 people (64%) answered Yes
Recently 3 of 7 people (43%) answered Yes

Entry

How to evaluate a php script within another script, and pass arguments to the first?

Sep 20th, 1999 02:18
Stéphane Rondinaud,


The "include" function allow a script to be evaluated within another 
script. But I thought it was impossible to pass the included script some 
parameters. The trick is that global vars are available to this 
inclusion, provided that they are declared "global" in this script.

See:

...
bar="echo Done!"
include("./script/foo.php3");
...

with foo.php3:

<?php

  global bar;

  print(bar);

?>

then the resulting code will be:

...
bar="echo Done!"
echo Done!
...

May be useful! ;)