Extension:Substring and strlen

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page Extension:Substring and strlen and the translation is 25% complete.

Other languages:
English • ‎polski • ‎日本語
MediaWiki 拡張機能マニュアル
OOjs UI icon advanced.svg
Substring and Strlen
リリースの状態: 安定
実装 Parser function
説明 This extension adds the ability to get string length and sub strings
作者 Brian Malinconico (Arjestalk)
ライセンス ライセンス未指定
ダウンロード バージョン 1 のコード
translatewiki.net で翻訳を利用できる場合は、Substring and strlen 拡張機能の翻訳にご協力ください
使用状況とバージョン マトリクスを確認してください。


This code snippet was created to help make templates reverse compatible. The idea is that #substring can be used in combination with the #if function to identify the version of the input string.


Copy the code from the download link on the right to your MediaWiki directory extensions directory/SubString/SubString.php

Then at the bottom of your LocalSettings.php file add the following code:

require_once($IP . "/extensions/SubString/SubString.php");


  • {{#substring:<string>|<start>|<length>}}

Please see https://secure.php.net/function.substr for more full documentation. In this implementation start defaults to 0. All parameters are sent directly to the php substr function so all valid php input should be valid for this function.

  • {{#strlen:<string>}}

Please see https://secure.php.net/function.strlen for more complete documentation. The value passed in <string> is passed directly to the php strlen function. If string is omitted (or blank) it will return a length of 0.