Page 1 of 1

seting $var then using it in implode ('', file ('FILE.php));

Posted: Mon Feb 03, 2003 12:44 pm
by Gregor
i have an example that looks like this:

index.php

Code: Select all

$variable = "something for the beggining";

// now i include file (but i cannot use the INCLUDE function)...
implode ('', file ('FILE.php));
FILE.php

Code: Select all

// that doesn't work!!!
echo $variable;
* is there any way to use the variable created in index.php in FILE.php without setting a cookie, creating session or moving it into FILE.php via address (FILE.php?variable=$variable)???

* it would be also much better if i could use INCLUDE function, the only thing is, i need that file to return a string, not in the way include() function does.

* the reason why i can't use include function is, becuase i don't output anything with echo or print but i save everything in a variable $template.. and if i do include function before the final echo $template, then the FILE won't be on the place where i want it to be..


any ideas? please help...

-thank you all ;)

Posted: Mon Feb 03, 2003 5:05 pm
by volka
you may use include anyway. e.g. try this

Code: Select all

<?php // included.php
return 'some text';
?>

Code: Select all

$text = 'and now ';
$text .= include('included.php');
echo $text;
?>