PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Ivan Gontarenko   PHP Number to Text Converter   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example usage NumConverter class
Class: PHP Number to Text Converter
Encode and decode numbers using character mappings
Author: By
Last change:
Date: 9 years ago
Size: 650 bytes
 

Contents

Class file image Download
<?php

   
use Utils\NumConverter;

    include_once
'./NumConverter.php';

   
$converter = new NumConverter(
       
NumConverter::USE_NUMS_WO_ZERO |
       
NumConverter::USE_LOWERCASE |
       
NumConverter::USE_UPPERCASE
   
);

   
$converter->addCustom( [
       
'_', '-', '%', '@', '+', '=', '!', ':', '~', ';', '(', ')', '^', '#', '[', ']', '{', '}'
   
] );

   
$number = bcmul( PHP_INT_MAX, 7 ); // 64563604257983430649

   
$encoded = $converter->encode( $number ); // 7@U1k6k6^-S

   
$decoded = $converter->decode( $encoded ); // 64563604257983430649

   
var_dump( $number, $encoded, $decoded ); die;