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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Gregor
Forum Newbie
Posts: 1
Joined: Mon Feb 03, 2003 12:44 pm

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

Post 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 ;)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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;
?>
Post Reply