Re: comparable Perl "unless" in PHP?

From: Date: Fri, 03 Nov 2000 00:53:07 +0000
Subject: Re: comparable Perl "unless" in PHP?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-23495@lists.php.net to get a copy of this message
If it did work (and I haven't tried it yet...) why not do the bolean algebra thing and shorten it to if !($field1 || $field2 || $field3 || $field4 || $field5) or if you want to check if the form variable has an empty or zero value if (empty($field1) || empty($field2) || empty($field3) || empty($field4) || empty($field5) ){ do form again... } Julian ----- Original Message ----- From: "Thomas Deliduka" <thomas@neweve.com> To: "PHP List" <php-general@lists.php.net> Sent: Thursday, November 02, 2000 8:13 PM Subject: Re: [PHP] comparable Perl "unless" in PHP? > I'm not the greatest of programmers but you could just make a negative If > statement: > > If (!$login....) > > or > if (!$field1 && !$field2 && !$field3 && !$field4 && !$field5) > > would this work? > > On 11/2/00 1:54 PM this was written: > > > as a recent migrant form Perl to PHP I've been going crazy trying to figure > > out how to use Perl's "unless" statement in PHP - or at least a workaround. > > > > For example, with Perl I was able to restrict access to certain pages using > > something like this: > > > > $login = $ENV{REMOTE_USER}; > > > > unless ($login =~ /^foo$|^bar$/) { > > > > print $query->redirect("../no_access.html"); > > } > > > > > > or - If I had a form with many fields I could do something to the effect of > > > > unless ($field1 && $field2 && $field3 && $field4 && > > $field5) { > > > > print "you did not complete all fields.\n"; > > > > } > > > > can someone please enlighten me as to how I could achieve this same > > functionality within PHP? I've searched through several books to no avail - > > the only thing I could find remotely similar was the "isset" function but > > that only seems to work with a single value and not groups. > > > > Any help would be greatly appreciated. I'd hate to have to go back to Perl > > so soon in the game ;) > > -- > > Thomas Deliduka > IT Manager > ------------------------- > New Eve Media > The Solution To Your Internet Angst > http://www.neweve.com/ > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#23495) next »