You are here: Re: Making functions available from another script « PHP « IT news, forums, messages
Re: Making functions available from another script

Posted by Norbert Wenzel on 11/07/05 11:12

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?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация