[PHP-DB] Re: [PHP] Problems w/ goto

2010-12-17 Thread Daniel P. Brown
On Fri, Dec 17, 2010 at 12:22, Robert Cummings  wrote:
>
> I was one of the people that argued in favour of GOTO on the Internals list
> a few years ago. GOTO has a use, and a very good one at that. It is by far
> the most efficient construct when creating parsers or other similar types of
> logic flow. The demonized GOTO of the 80s was primarily due to jumping to
> arbitrary points in the code, or in the case of basic to arbitrary line
> numbers in the code which had little meaning for future readers.

Not to mention failure to properly break, as in the OP's code example.

-- 

Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

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



Re: [PHP-DB] Re: [PHP] Problems w/ goto

2010-12-17 Thread Daniel Brown
On Fri, Dec 17, 2010 at 12:16, Richard Quadling  wrote:
>
> And have you seen all the sad faces ...
>
> : {
>
> on http://docs.php.net/manual/en/control-structures.goto.php#92763
>
> Can't be good for them.

If only people knew how many hours - literally, hours - it took me
to keep that page clean and free from vandalism after GOTO was
introduced.

-- 

Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

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



[PHP-DB] Re: [PHP] Problems w/ goto

2010-12-17 Thread Steve Staples
On Fri, 2010-12-17 at 12:22 -0500, Robert Cummings wrote:
> On 10-12-17 12:08 PM, Steve Staples wrote:
> > On Fri, 2010-12-17 at 10:50 -0600, Jay Blanchard wrote:
> >> [snip]
> >> Thank you with your excellent help in the past.  Here is another
> >> puzzler
> >>
> >> I am trying to write a program that can have two(2) independent forms
> >> in one PHP file.  When I run the code below [from PHP - A Beginner's
> >> Guide], to which I have added a second form, it freezes.  Without the
> >> goto statements, it runs.  When it does run, it displays both forms
> >> on one Web screen. What I desire is for the first form to be
> >> displayed, the data entered and then the second form displayed.  In
> >> an actual, not test program like this one, the data in the second
> >> form would be dependent on the first form.
> >>
> >> What did I do wrong?
> >> [/snip]
> >>
> >> You used GOTO.
> >>
> >> In this case I would recommend using something like jQuery to 'hide' one
> >> form until the other form is complete. PHP has sent the output to the
> >> browser already, both forms are there and display when you remove the
> >> GOTO.
> >>
> >> GOTO should never be used like this.
> >>
> >> GOTO should never be used.
> >>
> >
> > Wow... that brought me back to 1990... using basic and batch files...
> > I honestly didn't even know that the GOTO was still in existence,
> > especially within PHP.
> >
> > I had to show the people in my office, and we all got a chuckle from teh
> > XKCD comic in the PHP documentation for GOTO
> > http://ca2.php.net/goto
> >
> > Steve
> 
> I was one of the people that argued in favour of GOTO on the Internals 
> list a few years ago. GOTO has a use, and a very good one at that. It is 
> by far the most efficient construct when creating parsers or other 
> similar types of logic flow. The demonized GOTO of the 80s was primarily 
> due to jumping to arbitrary points in the code, or in the case of basic 
> to arbitrary line numbers in the code which had little meaning for 
> future readers. When used properly within a well defined scope and with 
> well named labels, GOTO can be a superior choice. If you think GOTO 
> doesn't exist in many types of software, you need only grep for it in 
> the C source code for PHP, MySQL, and Apache.
> 
> Cheers,
> Rob.

Oh, i can see where it would be useful, i just hadn't realized it was
still in existence...   and the cartoon, was blown up, and put in my
cubical :)

RAWR!!


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



[PHP-DB] Re: [PHP] Problems w/ goto

2010-12-17 Thread Daniel Brown
On Fri, Dec 17, 2010 at 11:38, Ethan Rosenberg  wrote:
>
> I am trying to write a program that can have two(2) independent forms in one
> PHP file.  When I run the code below [from PHP - A Beginner's Guide], to
> which I have added a second form, it freezes.
[snip!]
> What did I do wrong?

You presumed that "A Beginner's Guide" meant that it was a book
for beginners not one written by a beginner.  Firstly, while GOTO
has a place in programming for certain things, the example (and I can
see the difference between the original and your additions) is
atrocious, and is not at all representative of any code you would
ever, ever want to put into production.  That looks like a nightmare
of taking a math final, not knowing the answer, and suddenly realizing
you're in your underwear --- and have explosive uncontrollable
diarrhea on top of it, and your ankles are chained to the chair.  Who
is the author?  I saw one on Amazon by Vikram Vaswani, but there was
no use of GOTO that I could find there.  I'd like to see what other
"tips" are included, or perhaps to see if that code was used in a
different context (as in, "what will work, but what not to do anyway,"
or, "I wrote this on April Fool's Day").

-- 

Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

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



[PHP-DB] Re: [PHP] Problems w/ goto

2010-12-17 Thread Robert Cummings

On 10-12-17 12:08 PM, Steve Staples wrote:

On Fri, 2010-12-17 at 10:50 -0600, Jay Blanchard wrote:

[snip]
Thank you with your excellent help in the past.  Here is another
puzzler

I am trying to write a program that can have two(2) independent forms
in one PHP file.  When I run the code below [from PHP - A Beginner's
Guide], to which I have added a second form, it freezes.  Without the
goto statements, it runs.  When it does run, it displays both forms
on one Web screen. What I desire is for the first form to be
displayed, the data entered and then the second form displayed.  In
an actual, not test program like this one, the data in the second
form would be dependent on the first form.

What did I do wrong?
[/snip]

You used GOTO.

In this case I would recommend using something like jQuery to 'hide' one
form until the other form is complete. PHP has sent the output to the
browser already, both forms are there and display when you remove the
GOTO.

GOTO should never be used like this.

GOTO should never be used.



Wow... that brought me back to 1990... using basic and batch files...
I honestly didn't even know that the GOTO was still in existence,
especially within PHP.

I had to show the people in my office, and we all got a chuckle from teh
XKCD comic in the PHP documentation for GOTO
http://ca2.php.net/goto

Steve


I was one of the people that argued in favour of GOTO on the Internals 
list a few years ago. GOTO has a use, and a very good one at that. It is 
by far the most efficient construct when creating parsers or other 
similar types of logic flow. The demonized GOTO of the 80s was primarily 
due to jumping to arbitrary points in the code, or in the case of basic 
to arbitrary line numbers in the code which had little meaning for 
future readers. When used properly within a well defined scope and with 
well named labels, GOTO can be a superior choice. If you think GOTO 
doesn't exist in many types of software, you need only grep for it in 
the C source code for PHP, MySQL, and Apache.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



[PHP-DB] Re: [PHP] Problems w/ goto

2010-12-17 Thread Nicholas Kell

On Dec 17, 2010, at 11:08 AM, Steve Staples wrote:

[snip /]

>> 
>> 
>> GOTO should never be used like this.
>> 
>> GOTO should never be used.
>> 
> 
> Wow... that brought me back to 1990... using basic and batch files...
> I honestly didn't even know that the GOTO was still in existence,
> especially within PHP.
> 
> I had to show the people in my office, and we all got a chuckle from teh
> XKCD comic in the PHP documentation for GOTO
> http://ca2.php.net/goto
> 
> Steve

I didn't know it existed in PHP either. The cartoon is priceless. I should 
probably hang that up in my office somewhere.

[PHP-DB] Re: [PHP] Problems w/ goto

2010-12-17 Thread Richard Quadling
On 17 December 2010 17:08, Steve Staples  wrote:
> On Fri, 2010-12-17 at 10:50 -0600, Jay Blanchard wrote:
>> [snip]
>> Thank you with your excellent help in the past.  Here is another
>> puzzler
>>
>> I am trying to write a program that can have two(2) independent forms
>> in one PHP file.  When I run the code below [from PHP - A Beginner's
>> Guide], to which I have added a second form, it freezes.  Without the
>> goto statements, it runs.  When it does run, it displays both forms
>> on one Web screen. What I desire is for the first form to be
>> displayed, the data entered and then the second form displayed.  In
>> an actual, not test program like this one, the data in the second
>> form would be dependent on the first form.
>>
>> What did I do wrong?
>> [/snip]
>>
>> You used GOTO.
>>
>> In this case I would recommend using something like jQuery to 'hide' one
>> form until the other form is complete. PHP has sent the output to the
>> browser already, both forms are there and display when you remove the
>> GOTO.
>>
>> GOTO should never be used like this.
>>
>> GOTO should never be used.
>>
>
> Wow... that brought me back to 1990... using basic and batch files...
> I honestly didn't even know that the GOTO was still in existence,
> especially within PHP.
>
> I had to show the people in my office, and we all got a chuckle from teh
> XKCD comic in the PHP documentation for GOTO
> http://ca2.php.net/goto
>
> Steve
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

And have you seen all the sad faces ...

: {

on http://docs.php.net/manual/en/control-structures.goto.php#92763

Can't be good for them.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



[PHP-DB] RE: [PHP] Problems w/ goto

2010-12-17 Thread Steve Staples
On Fri, 2010-12-17 at 10:50 -0600, Jay Blanchard wrote:
> [snip]
> Thank you with your excellent help in the past.  Here is another
> puzzler
> 
> I am trying to write a program that can have two(2) independent forms 
> in one PHP file.  When I run the code below [from PHP - A Beginner's 
> Guide], to which I have added a second form, it freezes.  Without the 
> goto statements, it runs.  When it does run, it displays both forms 
> on one Web screen. What I desire is for the first form to be 
> displayed, the data entered and then the second form displayed.  In 
> an actual, not test program like this one, the data in the second 
> form would be dependent on the first form.
> 
> What did I do wrong?
> [/snip]
> 
> You used GOTO. 
> 
> In this case I would recommend using something like jQuery to 'hide' one
> form until the other form is complete. PHP has sent the output to the
> browser already, both forms are there and display when you remove the
> GOTO. 
> 
> GOTO should never be used like this.
> 
> GOTO should never be used.
> 

Wow... that brought me back to 1990... using basic and batch files...
I honestly didn't even know that the GOTO was still in existence,
especially within PHP.

I had to show the people in my office, and we all got a chuckle from teh
XKCD comic in the PHP documentation for GOTO
http://ca2.php.net/goto

Steve


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



[PHP-DB] RE: [PHP] Problems w/ goto

2010-12-17 Thread Jay Blanchard
[snip]
Thank you with your excellent help in the past.  Here is another
puzzler

I am trying to write a program that can have two(2) independent forms 
in one PHP file.  When I run the code below [from PHP - A Beginner's 
Guide], to which I have added a second form, it freezes.  Without the 
goto statements, it runs.  When it does run, it displays both forms 
on one Web screen. What I desire is for the first form to be 
displayed, the data entered and then the second form displayed.  In 
an actual, not test program like this one, the data in the second 
form would be dependent on the first form.

What did I do wrong?
[/snip]

You used GOTO. 

In this case I would recommend using something like jQuery to 'hide' one
form until the other form is complete. PHP has sent the output to the
browser already, both forms are there and display when you remove the
GOTO. 

GOTO should never be used like this.

GOTO should never be used.

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



[PHP-DB] Problems w/ goto

2010-12-17 Thread Ethan Rosenberg

Dear List -

I am sending this again since it does not seem to have posted.

Ethan
+++
Dear List -

Thank you with your excellent help in the past.  Here is another puzzler

I am trying to write a program that can have two(2) independent forms 
in one PHP file.  When I run the code below [from PHP - A Beginner's 
Guide], to which I have added a second form, it freezes.  Without the 
goto statements, it runs.  When it does run, it displays both forms 
on one Web screen. What I desire is for the first form to be 
displayed, the data entered and then the second form displayed.  In 
an actual, not test program like this one, the data in the second 
form would be dependent on the first form.


What did I do wrong?

Thanks in advance.

Here is the code:



http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
  
Project 4-4: Age Calculator
  
  
Project 4-4: Age Calculator
";
echo "  Enter your date of birth, in mm/dd/ format: ";
echo "  ";
echo "  ";
echo "  ";
echo "  ";

goto begin;
// if form submitted
// process form input
}
else
{
starter:
if (isset($_POST['cat']))
goto purr;
  // split date value into components
  $dateArr = explode('/', $_POST['dob']);

  // calculate timestamp corresponding to date value
  $dateTs = strtotime($_POST['dob']);

  // calculate timestamp corresponding to 'today'
  $now = strtotime('today');

  // check that the value entered is in the correct format
  if (sizeof($dateArr) != 3) {
die('ERROR: Please enter a valid date of birth');
  }

  // check that the value entered is a valid date
  if (!checkdate($dateArr[0], $dateArr[1], $dateArr[2])) {
die('ERROR: Please enter a valid date of birth');
  }

  // check that the date entered is earlier than 'today'
  if ($dateTs >= $now) {
die('ERROR: Please enter a date of birth earlier than today');
  }

  // calculate difference between date of birth and today in days
  // convert to years
  // convert remaining days to months
  // print output
  $ageDays = floor(($now - $dateTs) / 86400);
  $ageYears = floor($ageDays / 365);
  $ageMonths = floor(($ageDays - ($ageYears * 365)) / 30);
  echo "You are approximately $ageYears years and $ageMonths months old.";
  goto meow;
 }

meow:
if (!isset($_POST['dob']))
goto begin;
if (!isset($_POST['cat']))
{


echo "  ";
echo "  Enter your kitten's name: ";
echo "  ";
echo "  ";
echo "  Kitten\" />";

echo "";

}
else
{
purr:
$name_cat = $_POST['cat'];

echo "Your Kitten is $name_cat";
$ender = 1;
}
if ($ender == 0)
goto begin;
first_step:
?>

  




Ethan

MySQL 5.1  PHP 5  Linux [Debian (sid)]  




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