Re: Making functions available from another script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Richard Leclair wrote:
Hi PHP-ers,

Here's an easy one:
Q: How can I make a function available from within another php script?

Eg. B.php contains:

<?php include ".../fns.php" ?>

Which has a function fn($x);

Later on, I want to include this function in B.php somewhere.

In short:  B.php wants to use fn($x) found in A.php.

Regards,
Richie !

I'm not quite sure if I did get your question right, but you answered the question yourself.

include("anyfile.php"); does nothing more then "copy" the code of anyfile.php to the file, in which it is called. anyfile.php is interpreted as HTML, so you should have your <?php brackets around the document.

A.php-----------
function foo($bar) {
	//do sth
}

B.php-----------
include[_once]("A.php");

$x = "anything you like";
$whatever = foo($x);


this works if A and B are in exactly the same directory, otherwise you should change the path for the include call.

Did I get your question right?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux