Question: Suppose I am reading a web page and the [URL](http://en.wikipedia.org/wiki/Uniform_Resource_Locator) is "<http://example.com/term/11,23>". How can I use [PHP](http://en.wikipedia.org/wiki/PHP) to get ONLY the integer in the URL?

Answer: 
I would advice against such design. This type of static variables no better than global variables. [This page](http://c2.com/cgi/wiki?GlobalVariablesAreBad) gives a few reasons why you should avoid them. Here are a few of them.

* Non-locality
* No Access Control or Constraint Checking
* Implicit coupling
* Concurrency issues
* Testing and Confinement

> 
> But the token for OAuth2 needs to be assigned on runtime. Is this a good way to go... ?
> 
> 
> 

Here it really seems to me like you would want to pass such token to the constructor of the Prefs object.
Static variables are object-oriented substitutes for global variables in C. Try to avoid them whenever possible.

Many times you only need one object, in your case it's the Prefs object.

```
public class Prefs {

  //known before runtime
  public final String SERVER_BASE_URL ="http://api.mycompany.com/";

  //needs to be set on startup through the setter method
  private String token;

  public String getToken() {
    return token;
  }

  public void setToken( String token ) {
    Prefs.token = token;
  }

  public String getXyEndpointUrl() {
    return SERVER_BASE_URL + "/xy";
  }

}

public class Program {

  protected Prefs prefs;

  protected Other prefsAware;

  public Program() {
    prefs = new Prefs();
    prefsAware = new Other(prefs);
  }

  // or even (if you don't like constructor mediated passing of prefs)
  public Prefs getPrefs() {
    return prefs;
  }

}

```