Re: a function question

From: Date: Thu, 30 Dec 2004 15:09:40 +0000
Subject: Re: a function question
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-25207@lists.php.net to get a copy of this message
Here is my code (which I can't get to work): <?php
/** Note that my code / comments are untested, but should be helpful. */
        $mail = "FOJOMO@yahoo.com";
	$user = "patrick";       	function usermail( $user, $mail ) {
        
/** We don't need global $user or $mail since these are passed into the function. In fact doing this just might confuse yourself... */
        $user; = ucwords( $user ); // capitalizes the     //'p' in patrick
/** The above is incorrect. A semicolon terminates a line! Try the following: */ $user = ucwords( strtolower( $user ) );
        $mail; = strtolower( $mail ); // converts all
//of FOJOMO into lower case
$mail = strtolower( $mail );
  if ( strstr( $mail ), "@" )) {                      
/** Agreed with Graeme's previous comment, strpos is fine for this. */ if ( strpos( $mail, '@' ) ) {
    // searches for the '@' sign
user_array = explode("-", $user, $mail); // this
$user_array = explode( '-', $user);
//function (explode) creates the array
/** Check the manual page for explode http://php.net/manual/en/function.explode.php Why do you explode on hyphens? Do you have a system to prevent users from creating email addresses without hyphens? And what do you want to do with this array? */
} else { print "Please enter a valid e-mail address"; // default if test fails to //find the '@' sign }
/** Nothing is returned either... did you want something? */ return $user_array; } /** end of function usermail */ /** Now we test the function and echo the result of running the function. */ $result = usermail( $user, $mail ); print nl2br( print_r( $result ) );
?>
-- Teach a person to fish... Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html PHP Manual: http://php.net/manual/ php-general archives: http://marc.theaimsgroup.com/?l=php-general&w=2

« previous php.windows (#25207) next »