PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Dave Smith   Lucky Numbers   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example Usage
Class: Lucky Numbers
Generate numbers from text using numerology
Author: By
Last change:
Date: 8 years ago
Size: 2,906 bytes


Class file image Download
generate numbers from text using numerology
lucky number class 1.0

//include class

//instantiate object
$luckyNum = new luckyNum();

//process user input
if( !empty($_REQUEST['posted']) ){
//flag to process each line instead of words
$useLine = ( empty($_REQUEST['useLine']) ) ? false : true;
//amount of numbers to find
//find numbers within this range
//text to process
$luckyText = $_REQUEST['luckyText'];
//process text
    //note: you can run this method as many times as you wish with additional text before getting results
//get results
$luckyResult = $luckyNum->getLuckyResult();
//or set form defaults
$_REQUEST['numberCount'] = $luckyNum->numberCount;
$_REQUEST['lowRange'] = $luckyNum->lowRange;
$_REQUEST['highRange'] = $luckyNum->highRange;
$_REQUEST['luckyText'] = '';

        <title>Lucky Number Testing</title>
        <h3>Generate Lucky Numbers</h3>
        <h4>The lucky number class uses numeroligy to generate numbers from any supplied text. By default each word will represent a number, however you can also set it so that each line represents a number.</h4>
        <form method="POST">
            Lucky Numbers to Generate:<br>
            <input type="text" name="numberCount" value="<?PHP echo $_REQUEST['numberCount'];?>"><br><br>
            Low Number Range:<br>
            <input type="text" name="lowRange" value="<?PHP echo $_REQUEST['lowRange'];?>"><br><br>
            High Number Range:<br>
            <input type="text" name="highRange" value="<?PHP echo $_REQUEST['highRange'];?>"><br><br>
            Your Lucky Text:<br>
            <textarea name="luckyText" style="width: 600px;height: 200px;"><?PHP echo $_REQUEST['luckyText'];?></textarea><br>
            <input type="checkbox" name="useLine"<?PHP echo ( empty($_REQUEST['useLine']) ) ? '' : ' checked';?>> Calculate lucky numbers from each line<br><br>
            <input type="hidden" name="posted" value="1"><input type="submit" name="formSubmit" value="Get Lucky Numbers">
if( !empty($luckyResult) ){
            Lucky numbers requested: <?PHP echo $luckyResult['numberCount'];?><br>
            Lucky numbers found: <?PHP echo $luckyResult['resultCount'];?><br>
            Your lucky numbers: <strong><?PHP echo $luckyResult['resultSet'];?></strong>
            Object Values<br>
            <?PHP var_dump($luckyNum);?>