<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://compusofia.com/w/index.php?action=history&amp;feed=atom&amp;title=Manual%3AParser_functions%2Fen</id>
	<title>Manual:Parser functions/en - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://compusofia.com/w/index.php?action=history&amp;feed=atom&amp;title=Manual%3AParser_functions%2Fen"/>
	<link rel="alternate" type="text/html" href="https://compusofia.com/w/index.php?title=Manual:Parser_functions/en&amp;action=history"/>
	<updated>2026-04-18T19:31:33Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://compusofia.com/w/index.php?title=Manual:Parser_functions/en&amp;diff=5879&amp;oldid=prev</id>
		<title>FuzzyBot: Updating to match new version of source page</title>
		<link rel="alternate" type="text/html" href="https://compusofia.com/w/index.php?title=Manual:Parser_functions/en&amp;diff=5879&amp;oldid=prev"/>
		<updated>2026-04-12T10:25:30Z</updated>

		<summary type="html">&lt;p&gt;Updating to match new version of source page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;languages /&amp;gt;&lt;br /&gt;
{{Magic words}}&lt;br /&gt;
[[File:MediaWiki-extensions-icon.svg|125px|alt=MediaWiki extensions|{{dir|{{pagelang}}|left|right}}]]&lt;br /&gt;
Parser functions, added in MediaWiki 1.7, are a type of extension that integrate closely with the parser.&lt;br /&gt;
The phrase &amp;quot;parser function&amp;quot; should not be confused with {{ll|Extension:ParserFunctions}}, which is a collection of simple parser functions.&lt;br /&gt;
(See {{ll|Help:Extension:ParserFunctions}} for those.)&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
Whereas a [[Special:MyLanguage/Manual:Tag extensions|tag extension]] is expected to take unprocessed text and return HTML to the browser, a parser function can &amp;#039;interact&amp;#039; with other wiki elements in the page. For example, the output of a parser function could be used as a [[Special:MyLanguage/Help:Templates#Parameters|template parameter]] or in the construction of a [[Special:MyLanguage/Help:Link|link]].&lt;br /&gt;
&lt;br /&gt;
The typical syntax for a parser function is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
 {{ #functionname: param1 | param2 | param3 }}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information, see {{tmpl|0={{method doclink | class=MediaWiki\Parser\Parser | anchor=a34da5613dad9dd0a5e921aa7bceba3cf|method=$1}}|the documentation}} for {{phpi|Parser::setFunctionHook ( $id, $callback, $flags {{=}} 0 )}}.&lt;br /&gt;
This documentation states:&lt;br /&gt;
&lt;br /&gt;
:The callback function should have the form:&lt;br /&gt;
::&amp;lt;code&amp;gt;function myParserFunction( $parser, $arg1, $arg2, $arg3 ) { ... }&amp;lt;/code&amp;gt;&lt;br /&gt;
:Or with &amp;lt;code&amp;gt;SFH_OBJECT_ARGS&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;code&amp;gt;function myParserFunction( $parser, $frame, $args ) { ... }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first variant of the call passes all arguments as plain text.&lt;br /&gt;
The second passes all arguments as an array of {{ll|Manual:PPNode.php|PPNode}}s, except for the first (&amp;lt;code&amp;gt;$args[0]&amp;lt;/code&amp;gt;), which is currently text, though this may change in the future.&lt;br /&gt;
These represent the unexpanded wikitext.&lt;br /&gt;
The &amp;lt;code&amp;gt;{{ll|Manual:PPFrame.php|$frame}}&amp;lt;/code&amp;gt; parameter can be used to expand these arguments as needed.&lt;br /&gt;
This is commonly used for conditional processing so that only the {{phpi|true}} case is evaluated with an &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;-or-&amp;lt;code&amp;gt;switch&amp;lt;/code&amp;gt;-like parser function.&lt;br /&gt;
The frame object can also climb up the document tree to get information about the caller and has functions to determine and manage call depth, time-to-live, and whether the result of the parser function is volatile.&lt;br /&gt;
&lt;br /&gt;
Creating a parser function is slightly more complicated than creating a new tag because the function name must be a [[Special:MyLanguage/Help:Magic words|magic word]], a keyword that supports aliases and localization.&lt;br /&gt;
&lt;br /&gt;
== Simple example ==&lt;br /&gt;
&lt;br /&gt;
Below is an example of an extension that creates a parser function.&lt;br /&gt;
&lt;br /&gt;
The registration goes into &amp;#039;&amp;#039;&amp;#039;extension.json&amp;#039;&amp;#039;&amp;#039; and the code into &amp;#039;&amp;#039;&amp;#039;src/ExampleExtensionHooks.php&amp;#039;&amp;#039;&amp;#039; respectively:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Standard:&lt;br /&gt;
! Using the HookHandler interface:&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;| extension.json&lt;br /&gt;
|-&lt;br /&gt;
| {{ExtensionJsonFile&lt;br /&gt;
|type=parserhook&lt;br /&gt;
|extension=ExampleExtension&lt;br /&gt;
}}&lt;br /&gt;
| &lt;br /&gt;
{{Code&lt;br /&gt;
|lang=json&lt;br /&gt;
|&lt;br /&gt;
{&lt;br /&gt;
	&amp;quot;name&amp;quot;: &amp;quot;ExampleExtension&amp;quot;,&lt;br /&gt;
	&amp;quot;author&amp;quot;: &amp;quot;Me&amp;quot;,&lt;br /&gt;
	&amp;quot;version&amp;quot;: &amp;quot;1.0.0&amp;quot;,&lt;br /&gt;
	&amp;quot;url&amp;quot;: &amp;quot;https://www.mediawiki.org/wiki/Extension:ExampleExtension&amp;quot;,&lt;br /&gt;
	&amp;quot;descriptionmsg&amp;quot;: &amp;quot;{{lc:ExampleExtension}}-desc&amp;quot;,&lt;br /&gt;
	&amp;quot;license-name&amp;quot;: &amp;quot;GPL-2.0-or-later&amp;quot;,&lt;br /&gt;
	&amp;quot;type&amp;quot;: &amp;quot;parserhook&amp;quot;,&lt;br /&gt;
	&amp;quot;MessagesDirs&amp;quot;: {&lt;br /&gt;
		&amp;quot;ExampleExtension&amp;quot;: [&lt;br /&gt;
			&amp;quot;i18n&amp;quot;&lt;br /&gt;
		]&lt;br /&gt;
	},&lt;br /&gt;
	&amp;quot;AutoloadClasses&amp;quot;: {&lt;br /&gt;
		&amp;quot;ExampleExtensionHooks&amp;quot;: &amp;quot;src/ExampleExtensionHooks.php&amp;quot;&lt;br /&gt;
	},&lt;br /&gt;
	&amp;quot;ExtensionMessagesFiles&amp;quot;: {&lt;br /&gt;
		&amp;quot;ExampleExtensionMagic&amp;quot;: &amp;quot;ExampleExtension.i18n.php&amp;quot;&lt;br /&gt;
	},&lt;br /&gt;
	&amp;quot;Hooks&amp;quot;: {&lt;br /&gt;
		&amp;quot;ParserFirstCallInit&amp;quot;: &amp;quot;onParserFirstCallInit&amp;quot;&lt;br /&gt;
	},&lt;br /&gt;
	&amp;quot;HookHandlers&amp;quot;: {&lt;br /&gt;
		&amp;quot;ExampleExtensionHooks&amp;quot;: {&lt;br /&gt;
			&amp;quot;class&amp;quot;: &amp;quot;MediaWiki\\Extension\\ExampleExtension\\Hooks&amp;quot;&lt;br /&gt;
		}&lt;br /&gt;
	},&lt;br /&gt;
	&amp;quot;manifest_version&amp;quot;: 1&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;| ExampleExtensionHooks.php&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
class ExampleExtensionHooks {&lt;br /&gt;
&lt;br /&gt;
   // Register any render callbacks with the parser&lt;br /&gt;
   public static function onParserFirstCallInit( Parser $parser ) {&lt;br /&gt;
      // Create a function hook associating the &amp;lt;code&amp;gt;example&amp;lt;/code&amp;gt; magic word with renderExample()&lt;br /&gt;
      $parser-&amp;gt;setFunctionHook( &amp;#039;example&amp;#039;, [ self::class, &amp;#039;renderExample&amp;#039; ] );&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Render the output of {{#example:}}.&lt;br /&gt;
   public static function renderExample( Parser $parser, $param1 = &amp;#039;&amp;#039;, $param2 = &amp;#039;&amp;#039;, $param3 = &amp;#039;&amp;#039; ) {&lt;br /&gt;
      // The input parameters are wikitext with templates expanded.&lt;br /&gt;
      // The output should be wikitext too.&lt;br /&gt;
      $output = &amp;quot;param1 is $param1 and param2 is $param2 and param3 is $param3&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
      return $output;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
| &amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
class ExampleExtensionHooks implements ParserFirstCallInitHook {&lt;br /&gt;
&lt;br /&gt;
   // Register any render callbacks with the parser&lt;br /&gt;
   public function onParserFirstCallInit( $parser ) {&lt;br /&gt;
      // Create a function hook associating the example magic word with renderExample()&lt;br /&gt;
      $parser-&amp;gt;setFunctionHook( &amp;#039;example&amp;#039;, [ $this, &amp;#039;renderExample&amp;#039; ] );&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Render the output of {{#example:}}.&lt;br /&gt;
   public function renderExample( $parser, $param1 = &amp;#039;&amp;#039;, $param2 = &amp;#039;&amp;#039;, $param3 = &amp;#039;&amp;#039; ) {&lt;br /&gt;
      // The input parameters are wikitext with templates expanded.&lt;br /&gt;
      // The output should be wikitext too.&lt;br /&gt;
      $output = &amp;quot;param1 is $param1 and param2 is $param2 and param3 is $param3&amp;quot;;&lt;br /&gt;
      return $output;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Another file, &amp;#039;&amp;#039;&amp;#039;ExampleExtension.i18n.php&amp;#039;&amp;#039;&amp;#039;, in your extension directory (Not in the src/ subdirectory) should contain:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * @license GPL-2.0-or-later&lt;br /&gt;
 * @author Your Name (YourUserName)&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
$magicWords = [];&lt;br /&gt;
&lt;br /&gt;
/** English&lt;br /&gt;
 * @author Your Name (YourUserName)&lt;br /&gt;
 */&lt;br /&gt;
$magicWords[&amp;#039;en&amp;#039;] = [&lt;br /&gt;
   &amp;#039;example&amp;#039; =&amp;gt; [ 0, &amp;#039;example&amp;#039; ],&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this extension enabled,&lt;br /&gt;
&lt;br /&gt;
* {{#example: hello | hi | hey}}&lt;br /&gt;
&lt;br /&gt;
produces:&lt;br /&gt;
&lt;br /&gt;
* param1 is hello and param2 is hi and param3 is hey&lt;br /&gt;
&lt;br /&gt;
{{note|1=This magicWords array is not optional. If it is omitted, the parser function simply will not work; the {{#example: hello | hi}} will be rendered as though the extension were not installed. If only the language-specific array is initialized and not the magicWords array itself, this can cause localization errors as translations from other extensions leak into yours. You can associate magic words inline in PHP rather than through a i18n file. This is useful when defining hooks in &amp;lt;code&amp;gt;LocalSettings.php&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
MediaWiki\MediaWikiServices::getInstance()-&amp;gt;getContentLanguage()-&amp;gt;mMagicExtensions[&amp;#039;wikicodeToHtml&amp;#039;] = [&amp;#039;MAG_CUSTOM&amp;#039;, &amp;#039;custom&amp;#039;];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Within LocalSettings.php ===&lt;br /&gt;
&lt;br /&gt;
Magic words and their handling parser functions can be defined entirely in LocalSettings.php.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$wgHooks[&amp;#039;ParserFirstCallInit&amp;#039;][] = function ( Parser $parser ) &lt;br /&gt;
{&lt;br /&gt;
	MediaWiki\MediaWikiServices::getInstance()-&amp;gt;getContentLanguage()-&amp;gt;mMagicExtensions[&amp;#039;wikicodeToHtml&amp;#039;] = [&amp;#039;wikicodeToHtml&amp;#039;, &amp;#039;wikicodeToHtml&amp;#039;];&lt;br /&gt;
&lt;br /&gt;
	$parser-&amp;gt;setFunctionHook( &amp;#039;wikicodeToHtml&amp;#039;, &amp;#039;wikicodeToHtml&amp;#039; );&lt;br /&gt;
};&lt;br /&gt;
 &lt;br /&gt;
function wikicodeToHtml( Parser $parser, $code = &amp;#039;&amp;#039; ) &lt;br /&gt;
{&lt;br /&gt;
	$title = $parser-&amp;gt;getTitle();&lt;br /&gt;
	$options = $parser-&amp;gt;Options();&lt;br /&gt;
	$options-&amp;gt;enableLimitReport(false);&lt;br /&gt;
	$parser = $parser-&amp;gt;getFreshParser();&lt;br /&gt;
	return [$parser-&amp;gt;parse($code, $title, $options)-&amp;gt;getText(), &amp;#039;isHTML&amp;#039; =&amp;gt; true];&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Longer functions ===&lt;br /&gt;
&lt;br /&gt;
For longer functions, you may want to split the hook functions out to a _body.php or .hooks.php file and make them static functions of a class. Then you can load the class with {{ll|Manual:$wgAutoloadClasses|$wgAutoloadClasses}} and call the static functions in the hooks; e.g.:&lt;br /&gt;
&lt;br /&gt;
Put this in your &amp;lt;code&amp;gt;extension.json&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&amp;quot;Hooks&amp;quot;: {&lt;br /&gt;
	&amp;quot;ParserFirstCallInit&amp;quot;: &amp;quot;ExampleExtensionHooks::onParserFirstCallInit&amp;quot;&lt;br /&gt;
},&lt;br /&gt;
&amp;quot;AutoloadClasses&amp;quot;: {&lt;br /&gt;
	&amp;quot;ExampleExtensionHooks&amp;quot;: &amp;quot;src/ExampleExtensionHooks.php&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
* &amp;lt;small&amp;gt;See: [[Special:MyLanguage/Manual:Hooks#Writing_an_event_handler|writing an event handler]] for other styles.&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then put this in your &amp;lt;code&amp;gt;src/ExampleExtensionHooks.php&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class ExampleExtensionHooks {&lt;br /&gt;
      public static function onParserFirstCallInit( Parser $parser ) {&lt;br /&gt;
           $parser-&amp;gt;setFunctionHook( &amp;#039;example&amp;#039;, [ self::class, &amp;#039;renderExample&amp;#039; ] );&lt;br /&gt;
      }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Parser interface ==&lt;br /&gt;
&lt;br /&gt;
=== Controlling the parsing of output ===&lt;br /&gt;
&lt;br /&gt;
To have the wikitext returned by your parser function be fully parsed (including expansion of templates), set the &amp;lt;code&amp;gt;noparse&amp;lt;/code&amp;gt; option to {{phpi|false}} when returning:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
return [ $output, &amp;#039;noparse&amp;#039; =&amp;gt; false ];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It seems the default value for &amp;lt;code&amp;gt;noparse&amp;lt;/code&amp;gt; changed from {{phpi|false}} to {{phpi|true}}, at least in some situations, sometime around version 1.12.&lt;br /&gt;
&lt;br /&gt;
Conversely, to have your parser function return HTML that remains unparsed, rather than returning wikitext, use this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
return [ $output, &amp;#039;noparse&amp;#039; =&amp;gt; true, &amp;#039;isHTML&amp;#039; =&amp;gt; true ];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Naming ===&lt;br /&gt;
By default, MW adds a hash character (number sign, &amp;lt;code&amp;gt;#&amp;lt;/code&amp;gt;) to the name of each parser function.&lt;br /&gt;
To suppress that addition (and obtain a parser function with no &amp;lt;code&amp;gt;#&amp;lt;/code&amp;gt; prefix), include the &amp;#039;&amp;#039;SFH_NO_HASH&amp;#039;&amp;#039; constant in the optional flags argument to setFunctionHook, as described [[#The setFunctionHook hook|below]].&lt;br /&gt;
&lt;br /&gt;
When choosing a name without a hash prefix, note that transclusion of a page with a name starting with that function name followed by a colon is no longer possible. In particular, avoid function names equal to a namespace name. In the case that interwiki transclusion [https://lists.wikimedia.org/hyperkitty/list/mediawiki-l@lists.wikimedia.org/thread/3M53FBQ66B4EZNU6XMJQRFG3TVCW7WQO/] is enabled, also avoid function names equal to an interwiki prefix.&lt;br /&gt;
&lt;br /&gt;
=== The setFunctionHook hook ===&lt;br /&gt;
For more details of the interface into the parser, see the documentation for setFunctionHook in includes/Parser.php.&lt;br /&gt;
Here&amp;#039;s a (possibly dated) copy of those comments:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;function setFunctionHook( $id, $callback, $flags = 0 )&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Parameters:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* string $id – The magic word ID&lt;br /&gt;
* mixed $callback – The callback function (and object) to use&lt;br /&gt;
* integer $flags – Optional. Values:&lt;br /&gt;
:* &amp;lt;code&amp;gt;SFH_NO_HASH&amp;lt;/code&amp;gt; (1) – constant if you call the function without &amp;lt;code&amp;gt;#&amp;lt;/code&amp;gt;. &lt;br /&gt;
:* &amp;lt;code&amp;gt;SFH_OBJECT_ARGS&amp;lt;/code&amp;gt; (2) – if you pass a PPFrame object and array of arguments instead of a series of function arguments, for which [[#Description|see above]]. &lt;br /&gt;
:*Defaults to 0 (no flags).&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Return value:&amp;#039;&amp;#039;&amp;#039; The old callback function for this name, if any&lt;br /&gt;
&lt;br /&gt;
Create a function, e.g., &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#sum:1|2|3}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. The callback function should have the form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; style=&amp;quot;overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
function myParserFunction( $parser, $arg1, $arg2, $arg3 ) { ... }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The callback may either return the text result of the function, or an array with the text in element 0, and a number of flags in the other elements. The names of the flags are specified in the keys. Valid flags are:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Name !! Type !! Default&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| found || Boolean || {{phpi|true}}&lt;br /&gt;
| {{phpi|true}} if the text returned is valid and processing of the template must stop.&lt;br /&gt;
|-&lt;br /&gt;
| text || ? || ?&lt;br /&gt;
| The text to return from the function. If isChildObj or isLocalObj are specified, this should be a DOM node instead.&lt;br /&gt;
|-&lt;br /&gt;
| noparse || {{Tunit|id=125|content=Boolean}} || {{phpi|true}}&lt;br /&gt;
| {{phpi|true}} if text should not be preprocessed to a DOM tree, e.g. unsafe HTML tags should not be stripped, etc.&lt;br /&gt;
|-&lt;br /&gt;
| isHTML || {{Tunit|id=125|content=Boolean}} || ?&lt;br /&gt;
| {{phpi|true}} if the returned text is HTML and must be armoured against wikitext transformation. [[Manual talk:Parser functions#isHTML - almost but not _entirely|But see discussion]]&lt;br /&gt;
|-&lt;br /&gt;
| nowiki || {{Tunit|id=125|content=Boolean}} || usually {{phpi|false}}&lt;br /&gt;
| {{phpi|true}} if wiki markup in the return value (text) should be escaped.&lt;br /&gt;
|-&lt;br /&gt;
| isChildObj || {{Tunit|id=125|content=Boolean}} || ?&lt;br /&gt;
| {{phpi|true}} if the text is a DOM node needing expansion in a child frame.&lt;br /&gt;
|-&lt;br /&gt;
| isLocalObj || {{Tunit|id=125|content=Boolean}} || ?&lt;br /&gt;
| {{phpi|true}} if the text is a DOM node needing expansion in the current frame. The default value depends on other values and outcomes.&lt;br /&gt;
|-&lt;br /&gt;
| preprocessFlags || ? || {{phpi|false}}&lt;br /&gt;
| Optional {{ll|Manual:PPFrame.php|PPFrame}} flags to use when parsing the returned text. This only applies when noparse is {{phpi|false}}.&lt;br /&gt;
|-&lt;br /&gt;
| title || ? || {{phpi|false}}&lt;br /&gt;
| The {{ll|Manual:Title.php|Title}} object where the text came from.&lt;br /&gt;
|-&lt;br /&gt;
| forceRawInterwiki || {{Tunit|id=125|content=Boolean}} || ?&lt;br /&gt;
| {{phpi|true}} if interwiki transclusion must be forced to be done in raw mode and not rendered.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Expensive parser functions ===&lt;br /&gt;
{{see also|Manual:Template limits#Expensive parser function calls}}&lt;br /&gt;
&lt;br /&gt;
Some parser functions represent a significant use of a wiki&amp;#039;s resources and should be marked as &amp;quot;expensive&amp;quot;.&lt;br /&gt;
The number of expensive parser functions on any given page is limited by the {{ll|Manual:$wgExpensiveParserFunctionLimit|$wgExpensiveParserFunctionLimit}} setting.&lt;br /&gt;
What counts as expensive is left up to the function itself, but typically, anything that is likely to cause a delay that extends beyond simple processing of data should be considered.&lt;br /&gt;
This includes things like database reads and writes, launching a shell script synchronously, or file manipulation.&lt;br /&gt;
On the other hand, not all such functions should necessarily be tagged.&lt;br /&gt;
Semantic MediaWiki, for example, only marks a percentage of its database reads as expensive.&lt;br /&gt;
This is due to the fact that on certain data-intensive pages, it could easily overflow the normal expensive parser function limits.&lt;br /&gt;
In cases like this, the potential for noticeably slower performance that doesn&amp;#039;t get flagged as expensive is a trade-off to having the functionality that SMW offers.&lt;br /&gt;
&lt;br /&gt;
To mark your parser function as expensive, from within the body of the function&amp;#039;s code, use &amp;lt;syntaxhighlight lang=php inline&amp;gt;$result = $parser-&amp;gt;incrementExpensiveFunctionCount();&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
The return value will be {{phpi|false}} if the expensive function limit has been reached or exceeded.&lt;br /&gt;
&lt;br /&gt;
==Named parameters==&lt;br /&gt;
&lt;br /&gt;
Parser functions do not support named parameters the way templates and tag extensions do, but it is occasionally useful to fake it. Users are often accustomed to using vertical bars ( &amp;lt;code&amp;gt;|&amp;lt;/code&amp;gt; ) to separate arguments, so it&amp;#039;s nice to be able to do that in the parser function context, too. Here&amp;#039;s a simple example of how to accomplish this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot; style=&amp;quot;overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
function ExampleExtensionRenderParserFunction( &amp;amp;$parser ) {&lt;br /&gt;
	// Suppose the user invoked the parser function like so:&lt;br /&gt;
	// {{#myparserfunction: foo=bar | apple=orange | banana }}&lt;br /&gt;
&lt;br /&gt;
	$options = extractOptions( array_slice( func_get_args(), 1 ) );&lt;br /&gt;
&lt;br /&gt;
	// Now you&amp;#039;ve got an array that looks like this:&lt;br /&gt;
	// [foo] =&amp;gt; &amp;#039;bar&amp;#039;&lt;br /&gt;
	// [apple] =&amp;gt; &amp;#039;orange&amp;#039;&lt;br /&gt;
	// [banana] =&amp;gt; true&lt;br /&gt;
	// Continue writing your code...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Converts an array of values in form [0] =&amp;gt; &amp;quot;name=value&amp;quot; into a real associative array in form [name] =&amp;gt; value&lt;br /&gt;
 * If no = is provided, true is assumed like this: [name] =&amp;gt; true&lt;br /&gt;
 *&lt;br /&gt;
 * @param array string $options&lt;br /&gt;
 * @return array $results&lt;br /&gt;
 */&lt;br /&gt;
function extractOptions( array $options ) {&lt;br /&gt;
	$results = [];&lt;br /&gt;
	foreach ( $options as $option ) {&lt;br /&gt;
		$pair = array_map( &amp;#039;trim&amp;#039;, explode( &amp;#039;=&amp;#039;, $option, 2 ) );&lt;br /&gt;
		if ( count( $pair ) === 2 ) {&lt;br /&gt;
			$results[ $pair[0] ] = $pair[1];&lt;br /&gt;
		}&lt;br /&gt;
		if ( count( $pair ) === 1 ) {&lt;br /&gt;
			$results[ $pair[0] ] = true;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return $results;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
General and related guides:&lt;br /&gt;
&lt;br /&gt;
* {{ll|Manual:Developing extensions}}, or for more general information about extensions, see {{ll|Manual:Extensions}} and {{ll|Extensions FAQ}}.&lt;br /&gt;
* {{ll|Manual:Tag extensions}}&lt;br /&gt;
* {{ll|Manual:Magic words}}&lt;br /&gt;
&lt;br /&gt;
Code:&lt;br /&gt;
&lt;br /&gt;
* {{ll|Manual:Parser.php}}&lt;br /&gt;
* {{ll|Manual:Hooks/ParserFirstCallInit}}&lt;br /&gt;
* {{ll|Parser function hooks}} – an (incomplete) list of parser functions provided by core and extensions&lt;br /&gt;
* The [https://github.com/JeroenDeDauw/ParserHooks#parserhooks Parser Hooks] PHP library, which provides an object orientated interface for declarative parser hooks&lt;br /&gt;
* {{ll|Manual:Extension data}}&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&lt;br /&gt;
* The [[Special:MyLanguage/Extension:ParserFunctions|ParserFunctions extension]] is a well-known collection of parser functions.&lt;br /&gt;
* {{ll|Help:Extension:ParserFunctions}}&lt;br /&gt;
* {{ll|Category:Parser function extensions}}&lt;br /&gt;
&lt;br /&gt;
{{Extension development}}&lt;br /&gt;
&lt;br /&gt;
[[Category:MediaWiki development{{#translation:}}]]&lt;br /&gt;
[[Category:Parser extensions{{#translation:}}|*]]&lt;br /&gt;
[[Category:Wiki markup{{#translation:}}|Parser functions]]&lt;br /&gt;
[[Category:Customization techniques{{#translation:}}|Parser functions]]&lt;br /&gt;
[[Category:Sample code{{#translation:}}]]&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
	</entry>
</feed>