PHP code example of professional-wiki / message-builder

1. Go to this page and download the library: Download professional-wiki/message-builder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

professional-wiki / message-builder example snippets


interface MessageBuilder {
	/**
	 * @throws UnknownMessageKey
	 */
	public function buildMessage( string $messageKey, string ...$arguments ): string;
}

$messageBuilder = new ArrayMessageBuilder( [ 
	'hello-something' => 'Hello, $1!',
	'multi-argument-example' => 'foo $2 $1 bar $3', 
	'plural-example' => 'You have $1 {{plural:$1|item|items}} in your cart.',
] );

function someCode( MessageBuilder $messageBuilder ) {
	// Returns 'Hello, world!'
	$messageBuilder->getMessage( 'hello-something', [ 'world' ] );
}