Manual:Title.php

The MediaWiki software's  class represents article titles, which are used for many purposes, including:
 * as the human-readable text title of the article
 * in the URL used to access the article
 * the wikitext link to the article
 * the key into the article database

The class is instantiated with one of these formats. Once instantiated, the title can retrieved in other formats or queried for its attributes. is intended to be an immutable "value" class, so there are no mutator functions.

To instantiate, call one of the static factory methods:

Once instantiated, the other non-static accessor methods can be used, such as,  ,  , etc.

Title Structure
A title consists of an optional Interwiki prefix (such as "m:" for pages from [m:|mediawiki.org] or "de:" for German Wikipedia articles), followed by an optional namespace, followed by the remainder of the title.

Interwiki prefixes and namespaces have the same rules:
 * they must start with a letter
 * they may only contain digits, letters, the space character and the underscore character
 * they are case insensitive
 * they end with a colon
 * spaces and underscores may be used interchangeably

Interwiki prefixes and namespaces are only recognized if they are specifically allowed by the software. For example, "de:name" is a link to the article "name" in the German Wikipedia, because "de" is recognized as one of the allowable interwikis. The title "talk:name" is a link to the article "name" in the "talk" namespace of the current wiki, because "talk" is a recognized namespace. Both may be present, and if so, the interwiki must come first, for example, "m:talk:name". If a title begins with a colon as its first character, no prefixes are scanned for, and the colon is just removed. Note that because of these rules, it is possible to have articles with colons in their names. "E. Coli 0157:H7" is a valid title, as is "2001: A Space Odyssey", because "E. Coli 0157" and "2001" are not valid interwikis or namespaces.

Character mapping rules: Once prefixes have been stripped, the rest of the title processed this way: spaces and underscores are treated as equivalent and each is converted to the other in the appropriate context (underscore in URL and database keys, spaces in plain text). "Extended" characters in the 0x80..0xFF range are allowed in all places, and are valid characters. They are encoded in URLs. Other characters may be ASCII letters, digits, hyphen, comma, period, apostrophe, parentheses, and colon. No other ASCII characters are allowed, and will be deleted if found (they will probably cause a browser to misinterpret the URL). Extended characters are not urlencoded when used as text or database keys.

Canonical forms: the canonical form of a title will always be returned by the object. In this form, the first (and only the first) character of the namespace and title will be uppercased; the rest of the namespace will be lowercased, while the title will be left as is. The text form will use spaces, the URL and DBkey forms will use underscores. Interwiki prefixes are all lowercase. The namespace will use underscores when returned alone; it will use spaces only when attached to the text title.

needs some explanation: for "internal" articles, it should return the "page_id" field if the article exists, else it returns 0. For all external articles it returns 0. All of the IDs for all instances of Title created during a request are cached, so they can be looked up quickly while rendering wikitext with lots of internal links.

Example
To check and see if a given page already exists: Note that if the page does not exist, this will not create it. For that, see Manual:Article.php.