You are here: Re: [PHP] Value (not) being retuned by a function « PHP « IT news, forums, messages
Re: [PHP] Value (not) being retuned by a function

Posted by Robert Cummings on 12/11/05 22:03

On Sun, 2005-12-11 at 14:55, MARG wrote:
> Hi,
>
> I have this form:
> http://www.tuxdoit.com/newsletter.php
>
> If you care to check it, you'll see that
> http://www.tuxdoit.com/formsResult.php
>
> never returns the function value:
>
> formsResult.php:
> -------------------------------------
> <?php
> include('functions.php');
> ini_set("display_errors","On");
>
> $email = $_REQUEST['email'];
>
> $emailResult = isEmailOk($email);
>
> print($emailResult);
>
> if ($emailResult == 1)
> print('Email Ok');
> else
> print('Email is not Ok');
>
> ?>
> --------------------------------
>
> functions.php:
> --------------------------------
> <?php
>
> function isEmailOk($email) {
> print($email);
> if (!eregi
> ("^([-!#\$%&'*+./0-9=?A-Z^_`a-z{|}~^?])+@([-!#\$%&'*+/0-9=?A-Z^_`a-z{|}~^?]+\\.)+[a-zA-Z]{2,6}\$",
> $email))
> return 1;
>
> } // is EmailOk
>
> ?>
> -------------------------------
>
> Why is that happening ?

I would wager because there's a ! operator preceding the ereg() call.
Also you have very dirty code, your isEmailOk() function doesn't return
a value in the case that the if expression fails, it assumes PHP will
return something useful (PHP returns null, but relying on that is asking
for trouble, and I doubt you knew so in the first place).

Cheers,
Rob.
--
..------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация