View Single Post
08-07-2004, 05:57 PM
#32
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

Try this.
PHP Code:
<?php
/**
 * A simple remake of the ever-popular
 * "Hello World" application.
 *
 * Copyright 2004 Peter Cowburn <peter@cowburn.info>
 * You are free to modify, add-to and redistribute without my
 * written consent.  All I ask is that you acknowledge me as the
 * original author.
 */

Class HelloWorld
// Class for our HelloWorld Script
{
    
// Key holder
    
var $def_key = array();
    
    Function 
key($string)
    
// Work with our key
    
{
        
$temp = array();
        for (
$i=0$i<strlen($string); $i++)
        {
            
$temp[] = ord($string{$i}) - 97;
        }
        
$this->def_key $temp;
        return 
true;
    }
    
    Function 
clarify($input$key=null)
    
// Simple, it clarifies a string
    
{
        if (
$key === null)
        {
            
$key $this->def_key;
        }
        
$temp = array();
        for (
$i=0$i<count($key); $i++)
        {
            
$temp[$this->def_key[$i]] = str_rot13($input{$i});
        }
        
ksort($temp);
        
$temp join($temp'');
        return 
$temp;
        
// confused yet?
    
// Function clarify
    
//Class HelloWorld

/*
    **********
    Right, that's the Class over with.
    Now for the procedural elements.
    **********
*/

// Lets create the 'word' and 'key' variables
$word     'ybUq !ybJrey';
$key     'kfblgmeihcjd';

// Create a new instance of the HelloWorld class
$hello     = new HelloWorld;
// Play with a 'key' string
$hello->key($key);

// And call the clarify method of our HelloWorld object
$result $hello->clarify($word);

// Echo the result!
echo $result;

// The end
exit;
?>
- Salathe