Russ <mailto:[EMAIL PROTECTED]>
    on Wednesday, March 30, 2005 1:18 PM said:

> I'm new to php and linux. I am trying to replace a password program I
> used under windows with a mysql based login. I want to compare the
> first character of the first and last name of the user for a capital
> letter.

Why? What does that accomplish?

> <?php
> $fname=John;
> $lname=Smith;

Where's the quotes?

> if(strncmp(S,${lname},1) ===0) {
> ?>
> <h1>strncmp() must have returned returned non-false</h1>

non-false = true

> <?php
> } else {
>> 
> <h3>Strncmp() must have returned false</h3>
> <?php
> }
> ?>

Rewrite:

<?php

$fname = "John";
$lname = "Smith";

if(preg_match("/[A-Z]/", substr($fname ,0 ,1)))
{
  echo "first letter is uppercase.";
}
else
{
  echo "first letter is not uppercase";
}

?>

There might be a better way than a regex but that's the first thing that
came to my mind.


HTH,
Chris.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to