faqts : Computers : Programming : Languages : PHP

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

6 of 11 people (55%) answered Yes
Recently 4 of 8 people (50%) answered Yes

Entry

I want some while cycle in one script to call (x-times) the other script and give him the values of variables (which are each time other).

Feb 19th, 2008 22:12
dman, Mirko Nasato, lukas novak, http://www.ttnr.org


You cannot strictly pass variables to another script, but you can set
those variables in the main script and then include() the other script.
main.php:
<?php
for ($i = 1; $i <= 5; $i++) {
    $passed = "Line $i.";
    include('other.php');
}
?>
other.php:
<?php
echo "$passed\n";
?>
$ php -f main.php
Line 1.
Line 2.
Line 3.
Line 4.
Line 5.