SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: random include
-
Jul 21, 2003, 10:46 #1
- Join Date
- Apr 2003
- Location
- uk
- Posts
- 545
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
random include
Hey, i am looking for a way to show a random php include.
Any ideas ?
Cheers, Jon► j0n.org
-
Jul 21, 2003, 10:57 #2
- Join Date
- Jul 2001
- Location
- Michigan, USA
- Posts
- 414
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Edit:
Skip my post, go down to the next one. It's a better solution.
One method would be to build the include statement into a variable and eval it. For example, setup the variable $include_me. Have your includes have the same file name except for a number at the end.
You end up with something like:
PHP Code:$include_me = "include(\"include$rand.inc\" );
eval $include_me;
Last edited by Andy Tomaka; Jul 21, 2003 at 11:19.
-
Jul 21, 2003, 11:16 #3
- Join Date
- Jun 2003
- Location
- Waterloo, ON
- Posts
- 1,517
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Or, just to be nitpicky, for better performance, call the include directly:
PHP Code:include("include$rand.inc");
My name is Steve, and I'm a super-villian.
-
Jul 21, 2003, 11:19 #4
- Join Date
- Jul 2001
- Location
- Michigan, USA
- Posts
- 414
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
haha, nah, that's not to be nitpicky lieut_data. That's me being an idiot. I apologize for that. I had originally had a different idea to begin with and then realized it was much simpler with just putting the variable there...and forgot about not needing eval(). Thanks for pointing it out!
-
Jul 21, 2003, 11:29 #5
- Join Date
- Jun 2003
- Location
- Waterloo, ON
- Posts
- 1,517
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-- no worries, mate!
Glad to help!My name is Steve, and I'm a super-villian.
Bookmarks