Re: How do I convert from perl to php?

From: Date: Wed, 21 Nov 2001 05:07:01 +0000
Subject: Re: How do I convert from perl to php?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-75353@lists.php.net to get a copy of this message
<? $required = array('name','address','phone'); $has_empty = 0; foreach ($required as $var) { if (!is_set($$var)) $has_empty = 1; } if ($has_empty) print 'You left one empty.'; ?> You don't need to use the $has_empty variable, but I thought it would be better to just display the message once. Robin digital1@olypen.com wrote: > > I am a perl user trying to convert to php > > how would i turn this perl into php? > > use CGI; > > $name = param(name); > $address = param(address); > $phone = param(phone); > > @required = qw( name address phone ); > > foreach $key($required) > { > if (!$$key) { &out("You left one empty."); } > } > > ?? > > --------------------------------------------- > This message was sent using OlyPen's WebMail. > http://www.olypen.com > > The original message was received at Tue, 20 Nov 2001 14:05:28 -0800 > from mail.olypen.com [208.200.248.2] > > ----- The following addresses had permanent fatal errors ----- > <php-general@lists.php.ne> > (reason: 550 Host unknown) > > ----- Transcript of session follows ----- > 550 5.1.2 <php-general@lists.php.ne>... Host unknown (Name server: lists.php.ne: host not > found) > > ------------------------------------------------------------------------ > Reporting-MTA: dns; relay1.olypen.com > Received-From-MTA: DNS; mail.olypen.com > Arrival-Date: Tue, 20 Nov 2001 14:05:28 -0800 > > Final-Recipient: RFC822; php-general@lists.php.ne > Action: failed > Status: 5.1.2 > Remote-MTA: DNS; lists.php.ne > Diagnostic-Code: SMTP; 550 Host unknown > Last-Attempt-Date: Tue, 20 Nov 2001 14:05:28 -0800 > > ------------------------------------------------------------------------ > > Subject: Converting from being a perl user > Date: Tue, 20 Nov 2001 22:08:17 GMT > From: digital1@olypen.com > To: php-general@lists.php.ne > > how would i turn this perl into php? > > use CGI; > > $name = param(name); > $address = param(address); > $phone = param(phone); > > @required = qw( name address phone ); > > foreach $key($required) > { > if (!$$key) { &out("You left one empty."); } > } > > ?? > > --------------------------------------------- > This message was sent using OlyPen's WebMail. > http://www.olypen.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 (#75353) next »