How do you mean, it didn't work in other cases? Did the file(s) get included? did they execute? did they execute properly?
I'm thinking, just by looking at it, that the answer to the last question is "no". The reason why I say that can be shown in a very simple example: main.php <? $x = "hello world"; include "other.inc"; function test() { include "other.inc"; } test(); ?> other.inc <? echo "--> $x<br>\n"; ?> The value of $x wont get echoed out the second time because it's basically in the function, while the first isn't. If I've confused you, email me direct and I'll try to explain better Martin -----Original Message----- From: Justin French [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 28, 2002 2:33 PM To: php Subject: [PHP] using return in fucntions Hi all, I've USED fucntions, i've MODIFIED functions, but to date I haven't written much in the way of reuseable code/functions. I'm at the point now where I can identify what sort of code could better be controlled by a function library, and want to get started on creating my own. However, I'm getting snagged on the smallest things... but maybe i'm expecting too much from PHP, or asking the wrong questions. "return" seems to stump me the most. I've checked out the manual under "return" and "returning-values", but i'm still a little blank. I'm sure there are some tutorials out there, but can't really find any that attack it from the angle I need, as yet. Anyhoo, perhaps I can learn by example. I find myself doing a lot of include files, and have been writing this code: <? $file = "somedir/something.php"; if(file_exists($file)) { include($file); } else { echo "could not open file $file for inclusion"; } ?> I'm sure there's a better way, such as using or die("something"); ANYWAY, the above code seems to me like a good candidate for a function... something like safe_include('somedir/something.php'); So I had a go... <? function safe_include($file) { if(file_exists($file)) { include($file); } else { echo "could not open file $file for inclusion"; } } ?> ... and it worked in some instances, but did not in others (forgive me, it's been a while since I tested it). I'm sure return() should be used here, but I'm not sure how/where/why to use it, or more importantly, the purpose/reasoning behind it in comparison to "echo" etc etc. Many many many thanks in advance, and apologies for the the long email! Justin French -------------------- Creative Director http://Indent.com.au -------------------- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php