Page 1 of 1

GLOBAL'ing functions

Posted: Mon Dec 02, 2002 7:06 pm
by phice
I'm creating a large link indexing program.

What I want is to be able to allow the webmaster to copy a short code:

Code: Select all

<?php showlinks(4); ?>
and not have to include a file on each page.

Does GLOBAL have a function like this? That will be able to make a function global through the whole site?

Posted: Mon Dec 02, 2002 10:00 pm
by mydimension
when you declare/set something as global, it is set that way for the life of the script (the time it takes to execute). therefore, just because you write:
global $someVar;
in one script, dosen't mean it is available to your entire site without some extra work.

also, you cannot declare a function as global. to solve your problem you will have to include the file that defines the function.

Posted: Tue Dec 03, 2002 8:33 am
by phice
That's what I was thinking.