Writing PHP Code PHP can be written directly in HTML code Example:…

Question Answered step-by-step Writing PHP Code PHP can be written directly in HTML code Example:… Writing PHP Code PHP can be written directly in HTML code Example:  NOTE:  All PHP code must have a semicolon (;) at the end. QUESTION:  What does the echo statement do?   QUESTION: Write PHP code to output your name.   PHP FILES PHP can also be written in PHP files. PHP files must be named using the ___________________ extension. Why is this important?   It tells the PHP interpreter that there is PHP code in the file to evaluate. How to open a PHP file?           A  PHP file called testing.phpCopy and paste this code into the file:   Put your PHP file into XAAMP’s htdocs folder.Start XAMPP.Open internet browser.Type in:  http://localhost/testing.phpPHP SYNTAXSTRINGSDo you remember what a string is?A string is a word or phrase between quotes, like so: “Hello, world!”Example: Concatenating Strings     MATH IN PHP PHP uses the same operators as other languages (+, -, *, /) QUESTION: Write PHP code that calculates the output of this equation: 75 x 25 + 100     30 – 10 ANSWER:     VARIABLES All variables start with the dollar sign ( $) $myName = “Mike”;$myAge = 32; PRACTICE: Write the following PHP code:Declare a variable called $myNameDeclare a variable called $myAgeOutput a statement that says: “My name is: _________.  I am <> years old”replace ____ with the value of $myNamereplace <> with the value of $myAge     COMMENTS Create comments using two forward slashes (//) Comments are used to describe what the code does. Example:   PRACTICE: Insert a comment on line 8. Your comment should describe what the program does.   COMPARISON OPERATORS Comparison Operators allow us to compare values. The result of a comparison operator is always a TRUE or FALSE statement The comparison operators include:> , < , <=, >=, ==, !=, < = > PRACTICE: Is 7 equal to 5?  Write PHP code to output (echo) the result of comparing 7 to 5.   MY NAME IS RAJVEER KAUR       Computer Science Engineering & Technology Python Programming COMPUTER IN4074 Share QuestionEmailCopy link Comments (0)

Leave a Comment

Your email address will not be published. Required fields are marked *