Projects in PHP
The following programming projects were found on various websites
and seemed like they might be fun to try. Some are simple exercises,
while others are complex brainteasers. In other words, I was looking
for something to keep my mind busy. Feel free to try your hand at
any of these before looking at my solution. Maybe you can find a
better way. Enjoy!
All solutions on this page are in PHP. I will post solutions in
other languages (i.e. C++, VB, etc...) when I have the time.
~ The Fibonacci Sequence ~
The Fibonacci Sequence is the list of numbers such that the first
two numbers are ones (1) and each subsequent number is the sum of
the previous two numbers (i.e. 1, 1, 2, 3, 5, 8, 13...). This is a
pretty simple program to write. Here is my
solution.
The numbers in the sequence get big quickly. You might want to put
in a fault mechanism to stop when the numbers overflow. My solution
stops when the 59th number in the sequence (956722026041) is reached,
since PHP begins rendering the sequence in scientific notation after
this.
~ Prime Numbers ~
A prime number is a number that has exactly two factors, itself and
one. The smallest (and only even) prime is 2. Generating a list of
primes less than a certain number is a time consuming task, therefore
great for a programming project. Here is my
solution.
I've limited my solution to the list of primes less than 1000. Any
limit will do, but keep processing time in mind.
~ Base Conversion ~
The challenge here is to write an arbitrary base conversion utility.
It should be able to convert a number in any base into another base.
For example, 10 in decimal (base 10) is 1010 in binary (base 2).
Here is my solution.
I've limited my solution to bases 36 or lower in order to simplify
the list of possible digits to '0' through '9' and 'A' through 'Z'.
Theoretically, this can be extended to any base by using multiple
"digits" to represent each place, but that's overkill, don't you
think?
~ The Quine ~
By definition, a quine is a program that produces its own
complete source code as its only output. Sounds easy, doesn't it?
Give it a try, then look at my solution.
You will need to view the page source to read the solution as it
does not format as a visible HTML document. In IE, right-click and
select "View Source" to see the page source code.