Connecting Tech Pros Worldwide Forums | Help | Site Map

Write a function in a seperate place and call it in several php files

duzhidian@gmail.com
Guest
 
Posts: n/a
#1: May 26 '06
Hello all,

Since I need call a function in different php files, I want to put the
funcion in a seperate file instead of copying and pasting into each php
file.

The benefit is that when I change the function in one place, all the
programs will change when they call this function.

What should I do in the PHP?

Thanks.

Zhidian Du


Iván Sánchez Ortega
Guest
 
Posts: n/a
#2: May 26 '06

re: Write a function in a seperate place and call it in several php files


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

duzhidian@gmail.com wrote:
[color=blue]
> Since I need call a function in different php files, I want to put the
> funcion in a seperate file instead of copying and pasting into each php
> file.[/color]
[...][color=blue]
> What should I do in the PHP?[/color]

You should RTFM:

http://php.net/include

- --
- ----------------------------------
Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

Todo el mundo quiere llegar a viejo, pero nadie quiere serlo.- M. Held.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFEdqDo3jcQ2mg3Pc8RAtDgAJ9iYy/1W3BYMb3wLbmX2oBRa4mJQACcDLyK
OPlnmZO4GXdil/vbygAiT28=
=GvRi
-----END PGP SIGNATURE-----
lorento
Guest
 
Posts: n/a
#3: May 26 '06

re: Write a function in a seperate place and call it in several php files


<?php
//include functions
require_once ("lib/function1.php");
require_once ("lib/function2.php");

?>

regards,
Lorento
---
http://www.mastervb.net

Closed Thread