PHP Classes

File: test_x_base.php

Recommend this page to a friend!
  Classes of Uwe Stein   X base   test_x_base.php   Download  
File: test_x_base.php
Role: Example script
Content type: text/plain
Description: some examples
Class: X base
Convert numbers between different numeric bases
Author: By
Last change: .
Date: 13 years ago
Size: 1,143 bytes
 

Contents

Class file image Download
<?php
include("x_base.php");

echo
"<h4> Some Examples, object-data shown using var_dump</h4>";
echo
"Decimal 65535:<br>";
$a = new x_base(65535,10);
var_dump($a);

// change base and use lower letters
$a->toLower();
$a->setBase(16);
echo
"<b>changed to lower letters and changed the base to hex</b>";
var_dump($a);

// change number and Base
echo "<b>changed the number to binary 10101010 </b>";
$a->setNum(10101010,2);
$a->toLower();
var_dump($a);

$a->setNum(fffe,16);
echo
"<b>now Hex fffe converted to all number-systems(bases)</b>";
var_dump($a);
for (
$i=2; $i <= $a->getMaxBase(); $i++)
{
    echo
"<br><b>Base ".$i."</b> ".$a->getConvNum($i);
}

echo
"<br><br>And finally an example using the mixed set of digits in contrast to lower or upper case letters</b>";
echo
"<br><b>see the decimal value of Hex fffe</b>";
$a->setNum(fffe,16);
echo
"<br><br>with lower digits: <br>".$a->getDec();
var_dump($a);
$a->mixedDigits();
$a->setNum(fffe,16);
echo
"<br><br>and after setting the digit-set to mixed digits: <br>".$a->getDec();
var_dump($a);
?>