include file

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

 I have a.php that includes functions.php and b.php that also uses
some function in functions.php as follows.

<? php
include ("b.php");

For some reason, I got error message "somefunction() not found"
originated from b.php when I ran a.php. When I tried to ALSO include
functions.php in b.php, I got error message
Fatal error: Cannot redeclare somefunction() (previously declared in
functions.php. What am I missing? Thanks.

Re: include file wrote:
Quoted text here. Click to load it

Nothing - it should work.  Ensure your spelling is correct, and that you
are including the files you think you are.

If that doesn't work, you'll need to post some code so e can see what
you're doing.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: include file wrote:
Quoted text here. Click to load it

My guess is that you had someFunction() in functions.php and called
somefunction.php in b.php and that is why it didn't find it.  When you
included functions.php in b.php, and still left functions.php in a.php,
the function someFunction() became doubly defined -- which is not
allowed.  (The error message is always entirely in lower case, so it
might really have meant someFunction() ).

1 - Check that what you are calling in b.php is, indeed, what the
function is in functions.php.  Remember that case sensitivity counts.

2 - Change include (or require) to include_once (or require_once).  Use
include for things that you specifically want included in multiple
places and are NOT functions.  For example, you may have a dropdown list
and you want that to be included in several place, you might build the
<option value="...">something</option> with print statements and save it
in a separate file.  You would then include it in the several places
that in building the form.  NEVER omit t5he _once when the included file
contains functions.  Think of the added _once as similar to the C
preprocessor function #ifndef.

Re: include file

On Sat, 29 Nov 2008 18:30:27 -0800 (PST),
Quoted text here. Click to load it

In your case, you might want to stick to the `include_once' construct
to avoid erroneous multiple definitions.

As suggested, make sure your function in functions.php actually
exists and that it is spelled correctly in the calling scope.

$email = str_replace('sig.invalid', '', $from);

Site Timeline