|
-
Jan 28th, 2006, 05:55 AM
#1
[RESOLVED] Including PHP Files
Can you include PHP files at any place in your code or do you have to do it at the top of the file?
-
Jan 28th, 2006, 06:52 AM
#2
Re: Including PHP Files
At any place at all. Here's something I do:
Code:
function loadComponent($name)
{
$class = $this->config[$name]['class'];
include_once("$class.php");
return new $class;
}
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 28th, 2006, 08:01 AM
#3
Re: [RESOLVED] Including PHP Files
-
Jan 28th, 2006, 08:07 AM
#4
Re: [RESOLVED] Including PHP Files
There's a gotcha here, though. Suppose:
a.php
Code:
$global = 'hello, there';
include('b.php');
function foo()
{
include ('b.php');
}
b.php:
The first inclusion prints "hello, there". The second prints nothing. That's because PHP files are included as if the include statement was directly replaced by the contained code.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 29th, 2006, 08:45 AM
#5
Re: [RESOLVED] Including PHP Files
so you'd need a
inside the function before the include('b.php').
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|