Login   Register  
PHP Classes
elePHPant
Icontem

File: example1.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Andrej Bodor  >  dea num2word  >  example1.php  >  Download  
File: example1.php
Role: Example script
Content type: text/plain
Description: example
Class: dea num2word
Spell number with Serbian words
Author: By
Last change:
Date: 4 years ago
Size: 5,346 bytes
 

Contents

Class file image Download
<!doctype html public '-//w3c//dtd html 3.2//en'>
<html>
<head>
<title>DeaNum2Word example 1</title>
</head>
<body onload='document.getElementById("number").focus();'>
<form id='form' name='form' method='post' action=''><?
require_once('numtoword.class.php');
if (
$_POST[submit]){
   
$debug $_POST[debug];
   
$lang $_POST[lang];
   
$number $_POST[number];
   echo 
'<table border="1" width="100%" cellspacing="0">';
   echo 
'<tr><td colspan="2" bgcolor="#DDDDDD"><b>&nbsp;Number - </b>'.$_POST[number].'</td></tr>';
   if(!
$debug)echo '<tr><td colspan="2">With debug check:<br />- exception<br />- formatout<br />- formatdec</td></tr>';
   
$sep ' ';
   if(
$debug){
      
$t1 '<table border="1" width="100%" cellspacing="0">';
      
$t2 '</table><br />';
   }
   if(
$lang == 'sr' || $lang == 'srl' || $lang == ''){
      
$n2w = new  DeaNum2Word($number,'srl','DIN',$sep,$debug);
      
$out $n2w->Num2WordOut();
      echo 
$t1.'<tr><td width="20%"><b>&nbsp;srl - Serbian latin</b></td><td>'.$out.'<br /></td></tr>'.$t2;
   }

   if(
$lang == 'sr' || $lang == 'src' || $lang == ''){
      
$n2w = new  DeaNum2Word($number,'src','DIN',$sep,$debug);
      
$out $n2w->Num2WordOut();
      echo 
$t1.'<tr><td width="20%"><b>&nbsp;src - Serbian cyrillic</b></td><td>'.$out.'<br /></td></tr>'.$t2;
   }

   if(
$lang == 'hr' || $lang == ''){
      
$n2w = new  DeaNum2Word($number,'hr','',$sep,$debug);
      
$out $n2w->Num2WordOut();
      echo 
$t1.'<tr><td width="20%"><b>&nbsp;hr - Croatian</b></td><td>'.$out.'</td></tr>'.$t2;
   }

   if(
$lang == 'ru' || $lang == ''){
      
$n2w = new  DeaNum2Word($number,'ru','',$sep,$debug);
      
$out $n2w->Num2WordOut();
      echo 
$t1.'<tr><td width="20%"><b>&nbsp;ru - Russian</b></td><td>'.$out.'</td></tr>'.$t2;
   }

   if(
$lang == 'en' || $lang == ''){
      
$n2w = new  DeaNum2Word($number,'en','&pound;',$sep,$debug);
      
$out $n2w->Num2WordOut();
      echo 
$t1.'<tr><td width="20%"><b>&nbsp;en - English</b></td><td>'.$out.'</td></tr>'.$t2;
   }

   if(
$lang == 'de' || $lang == ''){
      
$n2w = new  DeaNum2Word($number,'de','&euro;',$sep,$debug);
      
$out $n2w->Num2WordOut();
      echo 
$t1.'<tr><td width="20%"><b>&nbsp;de - German</b></td><td>'.$out.'</td></tr>'.$t2;
   }

   if(
$lang == 'it' || $lang == ''){
      
$n2w = new  DeaNum2Word($number,'it','&euro;',$sep,$debug);
      
$out $n2w->Num2WordOut();
      echo 
$t1.'<tr><td width="20%"><b>&nbsp;it - Italian</b></td><td>'.$out.'</td></tr>'.$t2;
   }

   if(
$lang == 'pt' || $lang == ''){
      
$n2w = new  DeaNum2Word($number,'pt','',$sep,$debug);
      
$out $n2w->Num2WordOut();
      echo 
$t1.'<tr><td width="20%"><b>&nbsp;pt - Portuguese</b></td><td>'.$out.'</td></tr>'.$t2;
   }

   if(
$lang == 'sp' || $lang == ''){
      
$n2w = new  DeaNum2Word($number,'sp','',$sep,$debug);
      
$out $n2w->Num2WordOut();
      echo 
$t1.'<tr><td width="20%"><b>&nbsp;sp - Spanish</b></td><td>'.$out.'</td></tr>'.$t2;
   }

   
$langformat = array(1,'1',2,'2',3,'3',4,'4',5,'5',
         
6,'6',7,'7',8,'8',9,'9',10,'10',
         
11,'11',12,'12',13,'13',14,'14',15,'15',
          
16,'16',17,'17',18,'18',19,'19',
          
20,'20',30,'30',40,'40',50,'50',
          
60,'60',70,'70',80,'80',90,'90',
          
100,'100',200,'200',300,'300',400,'400',500,'500',
         
600,'600',700,'700',800,'800',900,'900',
         
1000,'1000',1000000,'1000000',1000000000,'1000000000',
         
'formatdec','if($decimal<>0)$fmt = \' - %s\';else $fmt = \'%s\';$dec = $this->Num2Word($decimal,$separator);');

   if(
$lang == 'fmt' || $lang == ''){
      
$n2w = new  DeaNum2Word($number,'','',$sep,$debug,$langformat);
      
$out $n2w->Num2WordOut();
      echo 
$t1.'<tr><td width="20%"><b>&nbsp;fmt - Format language</b></td><td>'.$out.'</td></tr>'.$t2;
   }

   echo 
'</table>';
//   echo '<br /><input type=button value=back onclick=self.location="example1.php";>';
//   die;
}
?>
<br />
<table border='1' width='100%' cellspacing='0'>
<tr><td width='20%'><b>&nbsp;Number:</b></td><td><input value='<?
echo rand(1,100000000000000)/100;
?>
'id='number' name='number' type='text' size='20'></td></tr>
<tr><td><b>&nbsp;Language:</b></td><td><input value='<?echo $_POST[lang];?>' id='lang' name='lang' type='text' size='20'></td></tr>
<!--<tr><td colspan='2'><b>&nbsp;Currency:</b></td><td><select name="currency" size="1"><option value="">All</option><option value="srl">Serbian latin</option><option value="hr">Croatian</option><option value="ru">Russian</option><option value="en">English</option><option value="de">German</option><option value="it">Italian</option><option value="pt">Portuguese</option><option value="sp">Spanish</option></select></td></tr>-->
<tr><td><b>&nbsp;Debug:&nbsp;</b><input type='checkbox' value='1' name='debug'></td><td><input type='submit' value='submit' name='submit'></td></tr>
</table><br />
<table border='1' width='100%' cellspacing='0'>
<tr><td width='20%' colspan='2'><b>&nbsp;Direct out:</b></td><td><?
$num 
rand(1,100000000000000)/100;
$n2w = new  DeaNum2Word($num,'en','&pound;',' ');
$out $n2w->Num2WordOut();
echo 
$num.'</td><td>'.$out;
?>
</td></tr></table>
<table><tr><td>&nbsp;<input type='submit' value='reset' name='reset'></td></tr></table>
</form>
</body>
</html>