Guess Gender ;-)

VN:F [1.6.9_936]
Rating: 5.0/10 (1 vote cast)

Just a simple function to demonstrate the use of a few very simple but useful functions of PHP. This function simply accepts a parameter ($relation) and returns the “Gender (sex)” of the relationship.

Here’s the function:

<?php
function guessGender($relation)
{
 $gen = "";
 $relation = ucwords(strtolower($relation));
 $relations = array(
      "Male" => array("Husband", "Son", "Father", "Brother"),
      "Female" => array("Wife", "Daughter", "Mother", "Sister")
 );

 foreach($relations as $gender => $relationType){
      if(in_array($relation, $relationType)){
           $gen = $gender;
      }
 }

 return $gen;
}
?>

For the ease of your understanding, I have linked each PHP function, language construct and other statements to Official PHP manual. Simply click on the provided links (in above code) to see the detailed information on each.

POST Variable

VN:F [1.6.9_936]
Rating: 0.0/10 (0 votes cast)

Used for passing variables between pages on the submission of forms. The twist is, it’s hidden from the user in the URL (address) bar of a browser.

GET Variable

VN:F [1.6.9_936]
Rating: 0.0/10 (0 votes cast)

Used for passing variables between pages on the submission of forms or manual entry in the URL (address) bar of your browser.

Variables

VN:F [1.6.9_936]
Rating: 0.0/10 (0 votes cast)

Variables allow you to store data values in memory and are very easy to create.