PHP code example of carrontiger / conversion

1. Go to this page and download the library: Download carrontiger/conversion 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/ */

    

carrontiger / conversion example snippets


use carrontiger\Conversion\BinaryConverter;

$binaryConverter = new BinaryConverter();

echo $binaryConverter->fromDecimal(123);
//  "01111011"

use carrontiger\Conversion\BinaryConverter;

$binaryConverter = new BinaryConverter();

echo $binaryConverter->toDecimal('01111011');
//  123

use carrontiger\Conversion\OctalConverter;

$octalConverter = new OctalConverter();

echo $octalConverter->fromDecimal(123);
//  "173"

use carrontiger\Conversion\BinaryConverter;

$octalConverter = new OctalConverter();

echo $octalConverter->toDecimal('173');
//  123

use carrontiger\Conversion\HexadecimalConverter;

$hexadecimalConverter = new HexadecimalConverter()

echo $hexadecimalConverter->fromDecimal(123);
//  "7B"

use carrontiger\Conversion\HexadecimalConverter;

$hexadecimalConverter = new HexadecimalConverter();

echo $hexadecimalConverter->toDecimal('7B');
//  123

use carrontiger\Conversion\CaseInsensitiveAlphaDecimalConverter;

$ciAlphaDecimalConverter = new CaseInsensitiveAlphaDecimalConverter()

echo $ciAlphaDecimalConverter->fromDecimal(123);
//  "3F"

use carrontiger\Conversion\CaseInsensitiveAlphaDecimalConverter;

$ciAlphaDecimalConverter = new CaseInsensitiveAlphaDecimalConverter();

echo $ciAlphaDecimalConverter->toDecimal('3F');
//  123

use carrontiger\Conversion\CaseSensitiveAlphaDecimalConverter;

$alphaDecimalConverter = new CaseSensitiveAlphaDecimalConverter()

echo $alphaDecimalConverter->fromDecimal(123);
//  "1z"

use carrontiger\Conversion\CaseSensitiveAlphaDecimalConverter;

$alphaDecimalConverter = new CaseSensitiveAlphaDecimalConverter();

echo $alphaDecimalConverter->toDecimal('1z');
//  123

use carrontiger\Conversion\AsciiDecimalConverter;

$asciiDecimalConverter = new AsciiDecimalConverter()

echo $asciiDecimalConverter->fromDecimal(123);
//  "1T"

use carrontiger\Conversion\AsciiDecimalConverter;

$asciiDecimalConverter = new AsciiDecimalConverter()

echo $asciiDecimalConverter->toDecimal('1T');
//  123