PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
print("Are you Red? (Y/N)");
fscanf(STDIN,"%s", $isRed);
print("Are you Peanut? (Y/N)");
fscanf(STDIN,"%s", $isPeanut);
if($isRed == "Y");
{
if($isPeanut == "Y");
{
print("\nYou are a red & peanut");
}
else
{
print("\nYou are red & plain");
}
}
else
{
if($isPeanut == "Y");
{
print("\nYou are a green peanut");
}
else
{
print("\nYou are a green & plain");
}
}
print("\n\nPRESS ENTER TO EXIT");
$dummy = fgets(STDIN);
?>
I am guessing that you are not using PHP on the command line (but maybe you are). To get input from the browser, the variables in the request will be in the one of the superglobal arrays $_GET or $_POST. So for example, if the URL was:
So you are using PHP on the command line you rascal.
First, I would recommend that if you want to write command line applications that you use C, Perl, Python, etc. (or Shell Script on Unix). The only reason I would suggest to use PHP on the command line is to use a single language for tools that work in conjunction with a PHP web application.
If you insist, then I would recommend reading this: