Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Tuesday, June 17, 2008

Generating Data with PHP

Pretty much claim to have forgotten how to handle a piece a code to be almost immediately jogged by a short search. Anyway have completed the string generator in PHP. Possibly the most interesting point of the exercise is the strings that are created - some are just plain weird.



The weirdness is possibly the main attraction especially if one is not limited to boring strings like alphabetical and alphanumeric - although a quick random ASCII will show if there are any problems. I extended my initial release to include generating printable ASCII in addition to using the full ASCII encoding. This means that the string offering is only missing the unicode option.

I would say that just writing the generated string straight to the web-page, does not result in the prettiest of output options but it serves the purpose (at least for now).

Monday, June 16, 2008

Restart on PHP

After a few years I've picked up on PHP again. I'm reminded of how powerful a language it is - as well as how much of it I've forgotten.

My primary goal in this exercise is to be able to generate random values that can be used as test data. I started with a class for generating random strings (alphabetical, alphanumeric and ASCII) along with various formats (all capitals, all lower, sentence, title and random) as either of fixed length or of random length within a range.

This was relatively simple. The issue and where the memory hole exists is in processing input so that the values can be generated as needed. I remember processing the POST variables as well as doing input validation with error messaging. The solution is probably quite simple, I just need to finish this before moving on to the next bunch of ideas.