PHP Classes
Icontem

File: example.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ersin Güvenç  >  byte converter class  >  example.php  
File: example.php
Role: Example script
Content type: text/plain
Description: example file
Class: byte converter class
Convert byte counts into KB, MB, GB and TB
 

Contents

Class file image Download
<?php

require "byte_converter.class.php";
//EXAMPLE AUTO CONVERT

if($_SERVER["REQUEST_METHOD"] == "POST") {
  
try{
  
$byte = new byte_converter;
  
$byte->set_limit("tb"); //show types up to tera byte
  
$result $byte->auto($_POST['integer'],$_POST['type']);
  }
catch (Exception $e) {echo $e;}
}
//1048576000

/* EXAMPLE MANUAL CONVERT
try{
$byte = new byte_converter;
$total = $byte->convert("128849018880","b","kb");
echo $total;
}catch(Exception $e) {echo $e;} */
?>

<html>
<head>
<title>Byte Converter</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>

<form action="" id="convert" method="post">
<input type="text" size="30" name="integer" />
<select name="type" size="1">
<option value="b">B</option>
<option value="kb" selected>KB</option>
<option value="mb">MB</option>
<option value="gb">GB</option>
<option value="tb">TB</option>
<option value="pb">PB</option>
<option value="eb">EB</option>
<option value="zb">ZB</option>
<option value="yb">YB</option>
</select>
<input type="submit" name="auto" value="Auto Convert" />
 <font size="2">* Enter a value forexample 1024 KB (and choose KB) or 3000 MB (and choose MB)</font>
</form>

<?php print_r($result); ?>

</body>

</html>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products