Prefix

A prefix is a word extension, placed before the name.

In linguistics, prefixes change the meaning of the word, and give it a new built meaning, based on the meanings of the word and the prefix. For example, reconnect is build with re, which means again, and connect which means connect. Reconnect is the action to connect again, after a previous connection was lost.

In PHP, prefixes are used for convention, where methods built with prefixes should deliver a specific behavior.

  • get: access a value

  • set: assign a value

  • with: use an option to apply a process

  • find: search for a value, and may fail if there are none

  • parse: analyzer a piece of data to understand it

  • Etc.

In older PHP version, prefixing variables used to hold the type of the variable.

A similar notion is the suffix, which is located at the end of the word. Another way to create word is word combinaison.

In recent PHP, prefixing names is done using namespaces. It is also required for extensions to use a distinct prefix, such as mysqli_ or pg_. This may not apply to all global functions, for backward compatibility reasons.

Related : Suffix, Word Combination, Namespaces