goto Statement in PHP
Notes:
PHP goto statement:
- goto statement transfers the control to the specified label
Note: a text followed by colon(:) symbol indicates a label
Ex: beginning: , end: etc.
Syntax:
goto labelText;
Ex 1: displaying first name, last name, & full name using goto statement
goto firstName;
firstName:
echo "Manjunath","<br/>";
goto end;
lastName:
echo "Chidre","<br/>";
goto end;
fullName:
echo "Manjunath Chidre","<br/>";
goto end;
end:
Ex 2: displaying 12345 using goto statement
$i = 1;
beginning:
if($i<6)
{
echo $i,"<br/>";
$i++;
goto beginning;
}
// displaying 12345 using while loop
$i=1;
while($i<6)
{
echo $i,"<br/>";
$i++;
}
Interview Questions:
1. PHP stands for ______________
a. Hypertext Preprocessor
b. Preprocessor Hypertext
c. Personal Home Processor
d. Personal Hypertext processor
Ans: a