RE: [PHP] Revised - Call a Function from a Local File

From: Date: Wed, 07 May 2003 01:24:05 +0000
Subject: RE: [PHP] Revised - Call a Function from a Local File
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-146610@lists.php.net to get a copy of this message
> This issue was originally posted as Calling a Function from a Remote File. > I've since tried a few things and im still having troubles. Help!? > > I've built my own home page that I'm hoping will serve as the "front end" > of > an application I purchased. I'd like to "call" some functions from the > application that build a couple of menu bars. > > I've tried including the file that the functions are in, but wherever I > place > the include it draws the included file and disregards all of my code after > the include. Okay, let's slow down here for a second. Using include() is just like taking what's in the included file and placing it into the original file. File1.php <?php echo "hello"; include('file2.php'); ?> File2.php <?php echo "world"; ?> Now, when File1.php runs, it's basically the same as having a file like the following: <?php echo "hello"; echo "world"; ?> But, if the include file _only_ contains functions, you will not get any output. The functions will be created, though. File3.php <?php function f() { echo "function"; } ?> Now, if file3.php is included, there will be no output, but you can call f() anywhere you want. File4.php <?php echo "hello"; include('file2.php'); include('file3.php'); echo "world"; f(); ?> Will result in: helloworldworldfunction So, when you are calling your include, from your description, I'm assuming you have text/code outside of your functions. So when you include that file, that text/code will display where your include() call is. Hope that helps and makes the mud a little clearer... :) ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/

« previous php.general (#146610) next »