tags:

views:

21

answers:

2

I am working with the Facebook PHP library. It creates an object called $facebook.

In order to access the object within my functions I have to pass the object along with other parameters I want the function to process.

Is there a better way or is passing the object to the function an appropriate practice?

A: 

In your function definition: global $facebook;.

fredley
A: 

Making the functions member functions of the facebook object. (though it won't be logicical for each and every function, it will make sense for quite some possible functions)

Funnily enough, the only thing that will actually change is that your object now becomes a "hidden" parameter instead of an actual one.

Jasper