PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of pod   Text 2 Phonome   test.php   Download  
File: test.php
Role: Example script
Content type: text/plain
Description: Example usage file to live in the same folder as the class.
Class: Text 2 Phonome
Convert English text to phonome representation
Author: By
Last change:
Date: 19 years ago
Size: 3,886 bytes
 

Contents

Class file image Download
<?php

require_once("phonome_class.php");

// set a default sentence
$default = "hello, now is the winter of our disco tent.";
// create an inmstance of the class
$obj_phonome = new phonome();
// read the version
$version = $obj_phonome->version();

// is there any form text or do we use the default??
$string = isset($_GET["string"]) ? $_GET["string"] : $default;
// get the word delimiter or use default
$word_delimiter = isset($_GET["word_delimiter"]) ? $_GET["word_delimiter"] : $obj_phonome->get_word_delimiter();
// get the phonome delimiter
$phonome_delimiter = isset($_GET["phonome_delimiter"]) ? $_GET["phonome_delimiter"] : $obj_phonome->get_phonome_delimiter();
// get the sentence delimiter
$sentence_delimiter = isset($_GET["sentence_delimiter"]) ? $_GET["sentence_delimiter"] : $obj_phonome->get_sentence_delimiter();
// do we say punctuation or not
$say_punctuation = isset($_GET["say_punctuation"]) ? true : false;
$checked = $say_punctuation ? " checked" : "";
// we're using english numbers, so set.....
$obj_phonome->set_decimal_delimiter(".");
$obj_phonome->set_thousands_delimiter(",");

// set the rest of the vars up....
$obj_phonome->set_word_delimiter($word_delimiter);
$obj_phonome->set_phonome_delimiter($phonome_delimiter);
$obj_phonome->set_sentence_delimiter($sentence_delimiter);
$obj_phonome->set_say_punctuation($say_punctuation);

// get the output....
$out_string = $obj_phonome->convert($string);

// show results and form....

echo "
<html>
<head>
<title>phonome class version
$version</title>

<style type=\"text/css\">
BODY
{
    COLOR: #000000;

    scrollbar-base-color: #ffffff;
    scrollbar-arrow-color: #000008;
    scrollbar-track-color: silver;
    scrollbar-highlight-color: #000000;
    scrollbar-3dlight-color:#673008;
    scrollbar-shadow-color: #673008;
    scrollbar-darkshadow-color: #000000;
}
.label
{
    color:red;
}
</style>


<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
</head>
<body text=\"#FFFFFF\">

<h1 align=\"center\">Phonome class tester</h1>

<form method=\"get\" action=\"test.php\">
<table width=\"90%\" align=\"center\" cellpadding=\"5\" cellspacing=\"5\" class=\"code\" border=\"0\">

    <tr>
        <td width=\"5%\">&nbsp;</td>
        <td align=\"right\" class=\"label\">
            input :
        </td>
        <td align=\"left\">
           
$string
        </td>
        <td width=\"5%\">&nbsp;</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td align=\"right\" class=\"label\">
            output :
        </td>
        <td align=\"left\">
           
$out_string
        </td>
        <td>&nbsp;</td>
    </tr>

<tr>
    <td width=\"5%\">&nbsp;</td>
    <td align=\"right\" class=\"label\">
        Text to convert :
    </td>
    <td align=\"left\">
        <textarea name=\"string\" rows=\"2\" cols=\"40\">
$string</textarea>
    </td>
    <td width=\"5%\">&nbsp;</td>
</tr>
<tr>
    <td width=\"5%\">&nbsp;</td>
    <td align=\"right\" class=\"label\">
        Word delimiter :
    </td>
    <td align=\"left\">
        <input type=\"text\" name=\"word_delimiter\" size=\"10\" value=\"
$word_delimiter\">
    </td>
    <td width=\"5%\">&nbsp;</td>
</tr>
<tr>
    <td width=\"5%\">&nbsp;</td>
    <td align=\"right\" class=\"label\">
        Phonome delimiter :
    </td>
    <td align=\"left\">
        <input type=\"text\" name=\"phonome_delimiter\" size=\"10\" value=\"
$phonome_delimiter\">
    </td>
    <td width=\"5%\">&nbsp;</td>
</tr>
<tr>
    <td width=\"5%\">&nbsp;</td>
    <td align=\"right\" class=\"label\">
        Sentence delimiter :
    </td>
    <td align=\"left\">
        <input type=\"text\" name=\"sentence_delimiter\" size=\"10\" value=\"
$sentence_delimiter\">
    </td>
    <td width=\"5%\">&nbsp;</td>
</tr>
<tr>
    <td width=\"5%\">&nbsp;</td>
    <td align=\"right\" class=\"label\">
        Say punctuation :
    </td>
    <td align=\"left\">
        <input type=\"checkbox\" name=\"say_punctuation\"
$checked>
    </td>
    <td width=\"5%\">&nbsp;</td>
</tr>
<tr>
    <td align=\"center\" colspan=\"5\">
        <input type=\"submit\" name=\"submit\" value=\"convert\">
    </td>
</tr>
</table>
</form>

</body>
</html>\n"
;

?>