A Contest...in PHP 5

liunx

Guest
Now...it has occured to me, that this forum is relatively less active then certain other forums. I have no idea how to change that.

However, I -do- have an idea for a great PHP 5 contest. Most other contests detail the programmer's ability to utilize the new things found in PHP5, but come on, that gets boring after a while! With that in mind, I'd like to kick things up a notch.

For this contest, you will be required to write fully functional code that looks like something. PHP is a free form language, meaning that it doesn't matter where we put whitespace (within certain restraints). Use -this- bit of functionality and create some ascii art with your PHP program. The winner will get a years free subscription to Penguins 'R Us, Ltd., an LLBean wannabe company that has yet to be created.

No purchase necessary, must be 23 years of age or other in order to qualify for subscription. Thank you, come again.

[Note]
Just to clarify, this is something you must do with the -source code- of your PHP program, not the output. ;)<?/*
/\ .oOOOOOOo.
#/ oOOOOOOOOOOo.
#/ OOOO' 'OOOO.
#/ OOOO' 'OOOO
#/ OOOO .OOOO
#/ .OOOO'
#/ .OOOO'
#/ .OOOO'
#{ .OOOO'
#\ OOOO'
#\ OOOO
#\ JGSO
#\
#\ .OO.
#\ OOOO
\/ 'OO'
*/?>

:DHaha..cheater :pmust be 23 years of age or other in order

So this means i can be any age does it :D;) Twas the point.<?php

abstract class Shape {

protected $string;
protected $strlen;

function __construct(){
$this->string = file_get_contents($_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']);
$this->string = preg_replace("/\\s{2}+|\\t+|\\n+|<\\?php|\\/\\?>/", "", $this->string);
$this->strlen = strlen($this->string);
}
}

interface ShapeI {
public function draw();
}

class Square extends Shape implements ShapeI {

private $total;
private $rowlen;

public function __construct($x){
parent::__construct();
$this->rowlen = $x;
$this->total = round($x * $x / 2);
}

final public function draw(){
$y = 0;
for($i = 0; $i < $this->strlen; $i++){
echo $this->string[$i];
$y++;
if($y == $this->rowlen){
echo "\n";
$y = 0;
}
if($i == ($this->total -1)){
$this->strlen - $this->total > 0 ? $r = $this->strlen - $this->total : $r = 0;
echo "$r characters were unused";
return;
}
}
}
}

$sq = new Square(36);
$sq->draw();

?>

There's a start. Let's see some pretty patterns ;)
 
Back
Top