>1) in a fuction, does a return statment automatically exit the function as
>well?
Yes. Nothing more will get executed inside the function after the "return;"
Some purists claim that you should *NEVER* have a return *ANYWHERE* except
the last line of a function.
EG:
# WRONG
function divide($numerator, $denominator){
if ($denomiator == 0){
return '';
}
else{
return $numerator/$denominator;
}
}
# RIGHT
function divide($numerator, $denominator){
$result = '';
if ($denominator == 0){
$result = '';
}
else{
$result = $numerator/$denominator;
}
return $result;
}
It probably seems "silly" here, but when your functions get to be three or
four screenfuls long, a "return" you aren't seeing on the monitor can
frequently get you very confused, very fast.
>2) can someone give me a better explination of $HTTP_POST_VARS
If you give somebody an HTML FORM (like those forms you fill out on-line),
after they fill it out, the PHP page that *proccess* the FORM page will find
all the data in an array named $HTTP_POST_VARS.
Actually, it got renamed to $_POST recently. (The old one will still work
for a while, but convert ASAP).
Sample HTML:
<HTML><BODY><FORM ACTION=process.php METHOD=POST>
<INPUT NAME=searchkey> <INPUT TYPE=SUBMIT NAME=search VALUE="Search">
</FORM></BODY></HTML>
Sample PHP:
(note the filename must match the ACTION= part above)
<?php
echo "Searchkey is ", $_POST['searchkey'], "<BR>\n";
echo "search button was clicked: ", isset($_POST['search']), "<BR>\n";
?>
You could even not "know" what fields are in the FORM, and just output all
of them:
(this would be a "replacement" process.php file)
<?php
while (list($variable, $value) = each($_POST)){
echo "$variable is $value<BR>\n";
}
?>
--
Like Music? http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php