Jump to content

Fun PHP?

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Zizzy

Zizzy

    Programmer

  • Members
  • PipPipPipPip
  • 108 posts
Does anyone here have any fun PHP scripts that were made from boredom? Or something that you've written for a little project/hobby? Post your pointless/boredom created code here! Whether it be some big project you've worked on for years, or something you whipped up in a half hour! Be sure to tell us what it does!

Here is a basic PHP script to solve an algebra problem! 2x + 3^3 - 6 = 14
<?php

//setting variables to the correct number


//2

$var2 = 2;

//1

$varx2 = 1;

//6

$var6 = 6;

//14

$var14 = 14;

//3

$var3 = 3;

//20

$var21 = 20;


//doing the math with addition, subtraction, multiplication

$varx2 = $var14 + $var6 - $var20 - ($var3 * $var3 * $var3);


//echo the division :-)

echo $varx2 / $var2;


//end script

?>

The out put is: -3.5

-Zizzy

#2
Microsuck

Microsuck

    Newbie

  • Members
  • PipPip
  • 14 posts
I was playing with the basic math functions back when I first started PHP, and wrote the following. I won't post a direct link since I don't want to get in trouble for advertising.

Click Here

#3
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
I've written a lot of scripts like this, oddly have lost all of them and cannot remember many.

GD was interesting fun, I wrote scripts

  • to generate static (with rand, or mt_rand, or some_custom_rng_here) and find visual patterns.
$rand = rand() % 1 == 0 ? 0 : 0xFFFFFF;
for($x = 0; $x < 500; $x++) {
  for($y = 0; $y < 500; $y++) {
     imagesetpixel($gd, $x, $y, $rand);
  }
}

  • upload a picture, and display all available filters (inverted, and whatnot) side by side. It looked quite interesting on sharp pictures.
Unicode:
  • Display a phrase in all available encodings, to see interesting encoding issues (see Mojibake)
  • Display every possible codepoint, by category (i.e. unicodePoint('misc-symbols'))
Token Parsers, collecting input from a text form, and calculating with GMP/BC for simple arbitrary calculations

I will be sure to post some examples here if I find them.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users