Forum Moderators: coopster

Message Too Old, No Replies

Are external functions to a script possible?

         

mealybar

5:55 pm on Oct 6, 2005 (gmt 0)

10+ Year Member



Heya,
I've come a little way in my time with php, and now I want to redesign my site with php in my mind, rather than the evolved html/php that I've had.

Is it possible to include a file of php functions to each page, for then that page to run the functions imported?

I invisage one file with all my functions in, and then every page imports this file to call up any of the functions I've written. This is just so I dont have to duplicate my functions code into each page.

I'm kinda hoping that there is something like this in php, however google has let me down so far :(

Cheers
Richard

jatar_k

6:06 pm on Oct 6, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



there is

if you put all of your functions in a file then you can include [php.net] that file.

Those functions are then available in the including file as if they were actualy there.

You could read through the docs regarding functions [php.net] as well

mealybar

3:37 pm on Oct 7, 2005 (gmt 0)

10+ Year Member



Cheers, I hadnt read the include file correctly. I thought it just parsed as html.

Just to clarify; an include file would look something like:

<?php
function laa() { ....}
?>

i.e. it needs the php tags round it yeah?

jatar_k

3:44 pm on Oct 7, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



exactly