functions within classes
Posted: Thu Aug 26, 2004 9:50 pm
I have two files one with miscellanous functions (call this x.php) in it and the other with a class (with associated functions, call this y.php).
Now in y.php I use a function that is contained in x.php. When I wrote the code I initially thought that I would have to include x.php in y.php if I wanted to use a function from it. However when it came time to run the code I got the error:
Fatal error: Cannot redeclare connectdb() (previously delcared....)
So I took the include part out of my code and now it works fine. So my question is: how come this works? how does php know where to pick this function from? thankyou.
Now in y.php I use a function that is contained in x.php. When I wrote the code I initially thought that I would have to include x.php in y.php if I wanted to use a function from it. However when it came time to run the code I got the error:
Fatal error: Cannot redeclare connectdb() (previously delcared....)
So I took the include part out of my code and now it works fine. So my question is: how come this works? how does php know where to pick this function from? thankyou.