• Register
Post tutorial RSS Object oriented name generator

An addendum and a rewrite of an old name generator.

Posted by on - Basic Server Side Coding

This is a rewrite of an old name generator as well as an addendum to the old name generator how-to guide here: Moddb.com


class NameGeneration
  //$vowel boolean - true for vowel, false for consonant
  function randLetter($vowel)
    $letter = "";
    $vowels = array("a", "e", "o", "u");
    $consonants = array("b", "c", "d", "v", "g", "t", "l", "f");
        case true:
        $letter = $vowels[array_rand($vowels, 1)];
        case false:
        $letter = $consonants[array_rand($consonants, 1)];
    return $letter;
  function generateName()
  $name = $this->randLetter(false) . "" . $this->randLetter(true) . "" . "" . $this->randLetter(false) . "" . $this->randLetter(true) . "" . $this->randLetter(true) . "";
  echo $name;

$newname = new NameGeneration;
$newname -> generateName();


this rewrite was done by request of a community member who wished an OOP (object oriented programming) version of the script. To note, it seems this name generator is better done in jQuery/JavaScript/PHP combo rather than PHP alone if you are going to make a serious website.

Salsa_Shark - - 1,293 comments


Reply Good karma Bad karma+3 votes
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.