Newbie Q: isset interpret?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Complete newbie here, no C or related language background; starting from
the basics.  I DO have Visual Basic 6 (non .NET) and batch file
experience, but that's all.

I have the following statement in a piece of code I chose to analyze.
It's from a captcha form script but it is a pretty standard thing in
many such scripts.
   I understand the first line fine.
<?php if(isset($error) && $error==1){
echo 'onload="document.forms[0].scratch_submit.focus()"';

But the echo statement confuses me.  Can anyone provide an English
language description of the echo line for me?
    In particular, the significance of [0] and the
    No problems understanding the use of {, }, ', " and ;.

   IS "scratch_submit" a PHP internal or is it an assigned variable?  I
see it used in so many different scripts that it appears to be part of
PHP (I'm using version 4 on XP-Pro and Xampp for a local server.), but I
can't find it referenced anywhere.

   Same question for ".focus"?

Thanks much for any assistance you can offer,


Re: Newbie Q: isset interpret?

Quoted text here. Click to load it

That's JavaScript.  PHP runs server side and generates a bunch of
output (typically HTML, but it doesn't have to be).  This output is
then sent back to the user-agent (typically a web browser) where it is
interpreted and/or executed.

What this means is that the code
onload="document.forms[0].scratch_submit.focus()" has no meaning to
PHP itself -- it's simply a string of text that will be sent back to
the browser.  The browser itself is then responsible for executing it.

As for what that JavaScript code actually does you'll need to ask in a
JS newsgroup.

Site Timeline