That example I gave was just an example. If you needed to pass the string through the function and then to the DB:
$firstname = "Tom";
$surname = "Brady";
// separate var in case you needed to use the name in this format on the site somewhere.
$fullname = $firstname . " " . $surname;
// set a var with the string you want to pass through the function.
$nameslug = slugify($fullname);
Now you would pass $firstname, $surname, and $nameslug to the DB. The only reason I would create a separate var $nameslug, is if I wanted/needed to use the $fullname var somewhere on the site to show both the firstname and surname separated by a space.