Fumigator
06-20-2006, 06:19 AM
I'm struggling with something concerning "require".
If I have code like this, with the "displaySQLerror()" function inside the included file "sqlerr.inc":
<?php
require "sqlerr.inc";
function func1() {
...
...
...
}
function func2() {
...
if (!result) {
displaySQLerror();
}
}
Then it all works fine. But, if I put the "require" statement after the functions in the main file, like this:
<?php
function func1() {
...
...
...
}
function func2() {
...
if (!result) {
displaySQLerror();
}
}
require "sqlerr.inc";
I get a "call to undefined function displaysqlerror" error. In fact, I changed the require statement to try to bring in a file that doesn't exist and I didn't get an error! So obviously, somewhere along the line, something's going wrong. Or is it that you need to put require statements up top? That makes no sense.
If I have code like this, with the "displaySQLerror()" function inside the included file "sqlerr.inc":
<?php
require "sqlerr.inc";
function func1() {
...
...
...
}
function func2() {
...
if (!result) {
displaySQLerror();
}
}
Then it all works fine. But, if I put the "require" statement after the functions in the main file, like this:
<?php
function func1() {
...
...
...
}
function func2() {
...
if (!result) {
displaySQLerror();
}
}
require "sqlerr.inc";
I get a "call to undefined function displaysqlerror" error. In fact, I changed the require statement to try to bring in a file that doesn't exist and I didn't get an error! So obviously, somewhere along the line, something's going wrong. Or is it that you need to put require statements up top? That makes no sense.