Question: In this project, you will modify a nested if statement so it instead uses a compound conditional expression. You will use logical opera- tors such
In this project, you will modify a nested if statement so it instead uses a compound conditional expression. You will use logical opera- tors such as || (or) and && (and) to execute a conditional or looping statement based on multiple criteria.
-
Create a new document in your text editor.
-
Typethedeclaration,element,docu- ment head, and
element. Use the strict DTD and Gas Prices as the content of theelement. -
Create a script section in the document body that includes the following variable declaration and nested if statement:
= 2) {
if ($GasPrice <=3) echo "
Gas prices are between
$2.00 and $3.00.";
} ?>
-
Modify the nested if statement you created in the previ- ous step so it uses a single if statement with a compound conditional expression. You need to use the && (and) logical operator.
-
Add an else clause to the if statement that displays Gas prices are not between $2.00 and $3.00 if the compound con- ditional expression returns FALSE.
-
Save the document as GasPrices.php in the Projects direc- tory for Chapter 2 and upload the document to the server.
-
Open the GasPrices.php file in your Web browser by enter- ing the following URL: http://
/PHP_Projects/ Chapter.02/Projects/GasPrices.php. -
Close your Web browser window.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
