Although I'm sure there is a way, the only problem with serial numbers in PHP is; you are giving the source code (essentially, concidering php is not compiled), and a saavy programmer could generally figure a way around it, a keygen would surely come out after that.
Even if you did employ a script that couldn't easily have serial numbers generated, one could go through the script and remove all of your checks for a valid serial number.
Might I recommend leaving out key features in a "demo" script, this is really the only method of ensuring registration.
If you can point out some scripts that are done in this way, i'd love to see it.