Re: Mixing eval() with include/require
| From: | php3 at developersdesk dot com | Date: | Sun, 24 Dec 2000 20:20:24 +0000 |
| Subject: | Re: Mixing eval() with include/require | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-31763@lists.php.net to get a copy of this message | ||
Addressed to: Mark Rogers <mark.rogers.news@hazelwick.co.uk>
<php-general@lists.php.net>
** Reply to note from Rasmus Lerdorf <rasmus@php.net> Sun, 24 Dec 2000 09:03:25 -0800 (PST)
>
> > Rasmus Lerdorf wrote
> > > I really don't understand why you don't just use an include file with
> > > functions and then call the function inside the loop. This is exactly
> > > what functions are for. Including a file repeatedly inside a loop, or
> > > calling eval() repeatedly is not a good approach.
> >
> > That's what I'm trying to do! I want to define the function based on the
> > content of an external file, then call that function from within the loop.
Like this?
file include.php
-----------------------------------------------------
Hello from include.php
<?
echo $Test;
?>
<BR><BR>
-----------------------------------------------------
file test.php
-----------------------------------------------------
<?
function Test( $Test ) {
require( 'include.php' );
}
for( $I =1; $I < 4; $I ++ ) {
Test( $I );
}
?>
-----------------------------------------------------
result:
Hello from include.php 1
Hello from include.php 2
Hello from include.php 3
Rick Widmer
Internet Marketing Specialists
http://www.developersdesk.com