Memeing in PHP

From Eric Florenzano

Rules:

  1. Implement a program that takes in a user’s name and their age, and prints hello to them once for every year that they have been alive.
  2. Post these rules, the source code for your solution, and the following list (with you included) on your blog.
  3. Bonus points if you implement it in a language not yet seen on the following list!

I’ve seen solutions in python, ruby, Java, C, lisp, and TCL.  I haven’t seen PHP, and I’ve never really done PHP…so without further ado…

<?php

print “What is your name: “;
$name=fgets(STDIN);

print “What is your age: “;
$age = fgets(STDIN);

for ($i = 0; $i < $age; $i++) {
    print “$i. Hello, $name”;
}
?>

And the output…

What is your name: Jerry Steele
What is your age: 33
0. Hello, Jerry Steele
1. Hello, Jerry Steele
2. Hello, Jerry Steele
3. Hello, Jerry Steele
4. Hello, Jerry Steele
5. Hello, Jerry Steele
6. Hello, Jerry Steele
7. Hello, Jerry Steele
8. Hello, Jerry Steele
9. Hello, Jerry Steele
10. Hello, Jerry Steele
11. Hello, Jerry Steele
12. Hello, Jerry Steele
13. Hello, Jerry Steele
14. Hello, Jerry Steele
15. Hello, Jerry Steele
16. Hello, Jerry Steele
17. Hello, Jerry Steele
18. Hello, Jerry Steele
19. Hello, Jerry Steele
20. Hello, Jerry Steele
21. Hello, Jerry Steele
22. Hello, Jerry Steele
23. Hello, Jerry Steele
24. Hello, Jerry Steele
25. Hello, Jerry Steele
26. Hello, Jerry Steele
27. Hello, Jerry Steele
28. Hello, Jerry Steele
29. Hello, Jerry Steele
30. Hello, Jerry Steele
31. Hello, Jerry Steele
32. Hello, Jerry Steele

Amazing that I’ll do this, but I won’t fill out those net forwards that my friends send me…

About these ads

One thought on “Memeing in PHP

  1. Pingback: Meme in Scala « Dwins’s Weblog

Comments are closed.