Regnus 5.5

The Random Text Scripting Language

The Regnus Parser For PHP


The Regnus Parser for PHP allows you to use Regnus scripts to generate random text and content on your own webpages. You may notice that the quoted text displayed on the front page of this site is different each time the page is refreshed; this is achieved using the Regnus Parser for PHP.

Santa met Maggie Thatcher. He said, "Know where I can get laid?" She replied, "No, but I do like toes." And so he castrated her.
Generated by the Regnus script Something Completely Different, by Ryan J. Bury

The parser can output content generated from a Regnus script in two different formats: either as an image, or as text. The text method is more powerful, as it allows you to seamlessly transclude Regnus-generated random content into your own page, to be displayed using your own styling rules. However, if you are not familiar with the basics of server-side scripting, you may find that the image method is much easier to implement in your site.

The image output method also allows you to generate content in situations where the use of PHP scripts is not possible (for example in a forum signature!)

Note: the Regnus Parser for PHP fully supports UTF-8 character encoding, so scripts parsed using this parser are recommended to be encoded in this format.

Information & Download

Parser Version
Regnus Specification

Using The Parser

The Regnus parser for PHP is very simple to use, but does require at least some very basic knowledge of PHP, as well as (of course) the use of PHP on your server.

Assuming you do have use of a PHP installation on your server, the first step you will need to take is downloading the Regnus Parser for PHP, unzipping the file, and uploading it to your web server. Once this is done, you can simply include it from your own scripts in the following fashion:


$Regnus_Script = "YourScript";
$Regnus_Label = "YourLabel";



YourScript must include the path and filename of the script you would like to generate text from, and is always calculated from the site root of your webpage, regardless of where the parser itself is located.

Note: YourScript can also be a URI, so if you would like, you can refer to a script located on another server, and the parser will happily access it via HTTP!

YourLabel should of course point to the Label in the script from which you would like to generate text.

Generating Image Output

The parser can also output text drawn onto an image. This is, of course, much more limited in its flexibility than true text content, but can be useful in contexts where it is not possible to call on PHP to generate text (for example in a forum signature).

Random text generated using Regnus:
Generated by the Regnus script Something Completely Different, by Ryan J. Bury

To access the image function of the parser, simply post an image tag in the (X)HTML of your page with its src attribute set to point to the parser, and use command line arguments to set the correct parameters. For example:

<img src="http://YourDomain/PathToParser/Regnus.php?output=image&amp;imagewidth=YourWidth&amp;script=YourScript&amp;label=YourLabel" alt="Random text generated using Regnus:" />

As you can see, the parser will accept its parameters from the command line when accessed via HTTP, so simply set the appropriate variables for YourScript (including the path or URI!) and YourLabel, and set YourWidth to the width (in pixels) of the image you would like to produce.

Note: the image has a minimum width of 150 pixels. Its height is determined by the amount of text generated from the script.

Note: if your script or Label names include any spaces, remember that you must replace these with "%20" in the URI.

Note: by default, the image is output in PNG format.

Additional Parameters

The Regnus Parser for PHP supports various parameters to control its behaviour, all of which can be set either using variables when calling the parser from a PHP script, or using command-line arguments in the URI when accessing the parser via HTTP.

The following parameters are supported:

PHP Variable
URI Parameter
Contains the path and filename of the Regnus script from which you would like to generate text.
PHP Variable
URI Parameter
Contains the name of the Label in the specified script from which you would like to start parsing.
Script Information
PHP Variable
URI Parameter
  • blurb
  • title
If this parameter is set, the parser will output the chosen meta-information (either the script's Title or Blurb) instead of generating text from the specified Label.
Output Type
PHP Variable
URI Parameter
  • text
  • image
Specifies whether the parser should output the generated text as text content or a PNG image. The default if unspecified is "text".
Image Width
PHP Variable
URI Parameter
This parameter sets the width (in pixels) of the image generated when outputting an image. If unspecified, the default is "150" (the minimum allowed width).
(X)HTML New Lines
PHP Variable
URI Parameter
  • br
If this parameter is set to "br", the parser will replace standard new-line characters in the generated text with the (X)HTML tag "<br />", which can be useful if you are displaying the generated text directly on a web document and need to markup the newlines as such.
Escape Ampersands
PHP Variable
URI Parameter
  • true
  • false
If "true", this parameter replaces all ampersands within the generated content with (X)HTML entities. By default, this is "true" if outputting text, and "false" if outputting an image.
Strip Tags
PHP Variable
URI Parameter
  • true
  • false
If "true", this parameter removes all (X)HTML tags from the generated content. By default, this is "true" if outputting an image, and "false" if outputting text.
PHP Variable
URI Parameter
Specifies the protocol (HTTP etc.) by which the script file should be requested. If set, the content of this parameter is prepended to the script address, primarily in order to workaround overzealous server security measures, which can sometimes be triggered by seeing a full URI passed as a parameter.


Please feel free to use the following link to let people know that your page is powered by Regnus!

<p>Random content on this page generated by the <a href="">Regnus</a> scripting language.</p>

Version History