php-windows Digest 30 Dec 2004 19:36:50 -0000 Issue 2519
Topics (messages 25205 through 25208):
Re: a function question
25205 by: Dean Hayes
25206 by: graeme
25207 by: Jason Barnett
Re: php performance terrible outside firewall
25208 by: Edward Tilley
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Try this i got this working without any problems prints everything out nice
an neetly
<?php
$mail = "[EMAIL PROTECTED]";
$user = "patrick";
/*
comment function to get on screen
function usermail($user,$mail)
{
*/
global $user;
global $mail;
$user = ucwords($user); // capitalizes the 'p' in patrick
$mail = strtolower($mail); // converts all of FOJOMO into lower
case
if (preg_match("/@/" , $mail)) { // searches for the '@' sign
// Used preg_match not strstr
/*
Place array details here that will work
i do not know of arrays yet so i can not help here
*/
echo "Valid email address and username details here<p>\n" . $user .
"\n<p>\n" . $mail . "<p>\n";
} else {
print "Please enter a valid e-mail address"; //default if test fails to
//find the '@' sign
}
// Function close
//}
?>
Dean "The Insane Guy" Hayes
<-- I design and i redesign but still i never designed true beauty like you
-->
~~~ Call me Insane call me Crazy but there is one thing i know i am That is
someone that shall reach peoples hearts with words ~~~
~~ PHP seems easy enough but what about this ASP now that looks hard ~~
From: Patrick Roane <[EMAIL PROTECTED]>
To: [email protected]
Subject: [PHP-WIN] a function question
Date: Wed, 29 Dec 2004 21:06:43 -0800 (PST)
I am trying to create a function that works with two
arguments. the 1st needs to be a suername. The 2nd
needs to be an email address. Next, I have to use case
conversion functions to capitalize the first letter of
the username and convert the email add. to lowercase
characters and finaly check that it contains the @
sign. If I can't find the @ character, return false:
otherwise, I return an array containing the converted
arguments.
Here is my code (which I can't get to work):
<?php
$mail = "[EMAIL PROTECTED]";
$user = "patrick";
function usermail( $user, $mail ) {
global $user;
global $mail;
$user; = ucwords( $user ); // capitalizes the
//'p' in patrick
$mail; = strtolower( $mail ); // converts all
//of FOJOMO into lower case
if ( strstr( $mail ), "@" )) {
// searches for the '@' sign
user_array = explode("-", $user, $mail); // this
//function (explode) creates the array
} else {
print "Please enter a valid e-mail address"; //
default if test fails to //find the '@' sign
}
?>
=====
----------------
"forget your lust for the rich man's gold. All that you need, is in your
soul. You can do this if you try. All that I want for you my son, is to be
satisfied"
~ Lynard Skynard
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
The function strpos might be better, preg_match is a bit of overkill
if (strpos($mail,'@') == false)
// error message
else
// okay message
graeme.
Dean Hayes wrote:
Try this i got this working without any problems prints everything out
nice an neetly
<?php
$mail = "[EMAIL PROTECTED]";
$user = "patrick";
/*
comment function to get on screen
function usermail($user,$mail)
{
*/
global $user;
global $mail;
$user = ucwords($user); // capitalizes the 'p' in patrick
$mail = strtolower($mail); // converts all of FOJOMO into
lower case
if (preg_match("/@/" , $mail)) { // searches for the '@' sign
// Used preg_match not strstr
/*
Place array details here that will work
i do not know of arrays yet so i can not help here
*/
echo "Valid email address and username details here<p>\n" . $user .
"\n<p>\n" . $mail . "<p>\n";
} else {
print "Please enter a valid e-mail address"; //default if test
fails to //find the '@' sign
}
// Function close
//}
?>
Dean "The Insane Guy" Hayes
<-- I design and i redesign but still i never designed true beauty
like you -->
~~~ Call me Insane call me Crazy but there is one thing i know i am
That is someone that shall reach peoples hearts with words ~~~
~~ PHP seems easy enough but what about this ASP now that looks hard ~~
From: Patrick Roane <[EMAIL PROTECTED]>
To: [email protected]
Subject: [PHP-WIN] a function question
Date: Wed, 29 Dec 2004 21:06:43 -0800 (PST)
I am trying to create a function that works with two
arguments. the 1st needs to be a suername. The 2nd
needs to be an email address. Next, I have to use case
conversion functions to capitalize the first letter of
the username and convert the email add. to lowercase
characters and finaly check that it contains the @
sign. If I can't find the @ character, return false:
otherwise, I return an array containing the converted
arguments.
Here is my code (which I can't get to work):
<?php
$mail = "[EMAIL PROTECTED]";
$user = "patrick";
function usermail( $user, $mail ) {
global $user;
global $mail;
$user; = ucwords( $user ); // capitalizes the
//'p' in patrick
$mail; = strtolower( $mail ); // converts all
//of FOJOMO into lower case
if ( strstr( $mail ), "@" )) {
// searches for the '@' sign
user_array = explode("-", $user, $mail); // this
//function (explode) creates the array
} else {
print "Please enter a valid e-mail address"; //
default if test fails to //find the '@' sign
}
?>
=====
----------------
"forget your lust for the rich man's gold. All that you need, is in
your soul. You can do this if you try. All that I want for you my son,
is to be satisfied"
~ Lynard Skynard
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin 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 = "[EMAIL PROTECTED]";
$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
--- End Message ---
--- Begin Message ---
Problem resolved. Turns out that my internal DNS server's configuration and
a misinstalled/configured web-statistics counter were to blame. PHP runs
great and a recent upgrade to mySQL added significant performance gains via
query caching...
"Edward Tilley" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> environment - PII 450, 1 Gb RAM, Windows 2000 Server, IIS 5, PHP 4.3.1,
> MySQL 4.0.23
>
> My php website screams on my local network segment but slows to a crawl
> everytime a remote user (someone outside my firewall) calls a php page. My
> processor goes to 100% for 2 to 5 seconds and php.exe becomes the top CPU
> consumer.
>
> Has anyone else seen this behaviour? I forward port 80 requests through
> the firewall presently and I think I have covered all of my DNS bases.
>
> Thanks for any help !
>
> Ed
--- End Message ---