How can I set global variables that I can use in any script I might run within my site?

Comments

nevets’s picture

Using globals is a bad practice so I wonder what you are actually trying to do.

TheOldGuy223’s picture

I want a place to set the credentials needed for an API,
Right now I have rewritten the credentials in every php script that accesses the API, but If the credentials change later, I have to go through every script to make the change.

I need a place where I can define the credentials once and access then from any script inside of drupal. Maby using the term "global" was incorrect, but thats what Im trying to do.

nevets’s picture

In Drupal one would typically make a settings/configuration page for setting the values for the API. For system configuration forms they often end with a return of system_settings_form($form); in which case the values are stored in the variable table using the form element names. One can then use variable_get() to retrieve the values.