>> DAVID MALAN: Let's write a program in PHP that prompts the user for an
integer and then determines whether that integer is
positive, 0, or negative.
Here in conditions-1.php, I've already gotten us started by opening and
closing a PHP tag.
Let's first declare a variable, simply by doing $n.
The dollar sign indicates that this is a variable, and notice that we don't
need to provide a data type.
>> Let's now call a function called readLine, which is similar in spirit
to getString in the CS50 library for C. But readLine also takes an argument
that specifies the prompt that you'd like to show to the user.
For instance, I'd like an integer please.
>> Let's now analyze the user's input.
If n is greater than 0, then let's print out with printf, you picked a
positive number.
else if n equals 0, then let's print out with printf, you picked 0.
And lastly, else if the number is presumably negative, let's print out
with printf, you picked a negative number.
>> Let's now save this file and pass it through to the PHP interpreter--
php conditions-1.php.
I'd like an integer please.
How about 50?
A positive number.
>> Let's run it again with, say, 0.
I picked 0.
Let's run it again with, say, negative 50.
And I indeed picked a negative number.
But notice, most importantly, just how similar this syntax is to C.