Question

In: Computer Science

1. Create a PHP page with standard HTML tags. Remember to save the file with the...

1. Create a PHP page with standard HTML tags. Remember to save the file with
the .php extension.
Inside the <body> tag, create a PHP section that will show the text "Hello
World!"
2. For this exercise, echo the phrase "Twinkle, Twinkle little star." Create
two variables, one for the word "Twinkle" and one for the word "star". Echo
the statement tothe browser.
3. PHP includes all the standard arithmetic operators. For this PHP
exercise, you will use them along with variables to print equations to the
browser. In your script, create the following variables:
$x=10;
$y=7;
Write code to print out the following:
10 + 7 = 17
10 - 7 = 3
10 * 7 = 70
10 / 7 = 1.4285714285714
10 % 7 = 3
Use numbers only in the above variable assignments, not in the echo
statements. You will need a third variable as well.
Note: this is intended as a simple, beginning exercise, not using arrays or
loops.
4. Arithmetic-assignment operators perform an arithmetic operation on the
variable at the same time as assigning a new value. For this PHP exercise,
write a script to reproduce the output below. Manipulate only one variable
using no simple arithmetic operators to produce the values given in the
statements.
Hint: In the script each statement ends with "Value is now $variable."
Value is now 8.
Add 2. Value is now 10.
Subtract 4. Value is now 6.
Multiply by 5. Value is now 30.
Divide by 3. Value is now 10.
Increment value by one. Value is now 11.
Decrement value by one. Value is now 10.

Solutions

Expert Solution

Question 1

<!DOCTYPE>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body>

        <?php
            echo "Hello World";
        ?>

    </body>
</html>

Code

Output

Question 2



<!DOCTYPE>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body>

        <?php
            $word1 = "Twinkle";
            $word2 = "star";

            echo $word1.", ".$word1." little ".$word2;
            
        ?>

    </body>
</html>

Code

Output

Question 3


<!DOCTYPE>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body>

        <?php

            $x = 10;
            $y = 7;
            $res = $x + $y;
            print($x." + ".$y." = ".$res."<br>");
            $res = $x - $y;
            print($x." - ".$y." = ".$res."<br>");
            $res = $x * $y;
            print($x." * ".$y." = ".$res."<br>");
            $res = $x / $y;
            print($x." / ".$y." = ".$res."<br>");
            $res = $x % $y;
            print($x." % ".$y." = ".$res."<br>");
            
        ?>

    </body>
</html>

Code

Output

Question 4

<html>
    <body>
        <?php
            $x = 8;
            echo "Value is now ".$x."<br>";
            $y = 2;
            echo "Add ".$y.".";
            $x = $x + $y;
            echo "Value is now ".$x.".<br>";
            $y = 4;
            echo "Subtract ".$y.".";
            $x = $x - $y;
            echo "Value is now ".$x.".<br>";
            $y = 5;
            echo "Multiply by ".$y.".";
            $x = $x * $y;
            echo "Value is now ".$x.".<br>";
            $y = 3;
            echo "Divide by ".$y.".";
            $x = $x / $y;
            echo "Value is now ".$x.".<br>";
            echo "Increment value by one. ";
            $x++;
            echo "Value is now ".$x.".<br>";
            echo "Decrement value by one. ";
            $x--;
            echo "Value is now ".$x.".<br>";  
        ?>
    </body>
</html>

Code

Output


Related Solutions

Create 1 HTML page and 1 CSS file for all the styles. Your html page will...
Create 1 HTML page and 1 CSS file for all the styles. Your html page will be a small gallery of images using the Polaroid style. The page should have at least 1 row of 3 images. You can choose any theme of images. Don't pick random images, make them all have a theme. Add an h1 tag for the header of your page. Style the h1 tag with a color, size, and font family. Include a paragraph tag under...
PHP Question - Subject: PHP File Handling and Uploads INSTRUCTIONS: Objective: • Create a sticky HTML...
PHP Question - Subject: PHP File Handling and Uploads INSTRUCTIONS: Objective: • Create a sticky HTML form. • Submit form for processing. • Sanitize and validate form data. • Upload a profile image. • Add a record to a text file. • Display form results with content from another text file and the uploaded image. Description: This assignment deals with file management. It requires the use of 3 new files and 1 new directory. You will create the new file-uploads.php...
PHP Question - Subject: PHP File Handling and Uploads INSTRUCTIONS: Objective: • Create a sticky HTML...
PHP Question - Subject: PHP File Handling and Uploads INSTRUCTIONS: Objective: • Create a sticky HTML form. • Submit form for processing. • Sanitize and validate form data. • Upload a profile image. • Add a record to a text file. • Display form results with content from another text file and the uploaded image. Description: This assignment deals with file management. It requires the use of 3 new files and 1 new directory. You will create the new file-uploads.php...
I already have a database in phpMyAdmin and need to create an html/php "SEARCH" page to...
I already have a database in phpMyAdmin and need to create an html/php "SEARCH" page to retrieve the information from the database on to my localhost. Please post a php/html code that will create a search page and return the data from my phpmyadmin database. The 3 items I have on the database are first_name, last_name and birth_day.
Create a web page using PHP and HTML that contains a list of movie names available...
Create a web page using PHP and HTML that contains a list of movie names available for rent (at least 10 movies), so that each time you visit the home page, you see a different order of movies in the list. The movie names are required. 2) The rental price for each movie ranges between $1.99 to $7.99. • Create an associative array with a code for the movie as the key (e.g., movie1, movie2, etc.) and the associated rental...
Create 6 tags with text inside them (in a valid HTML page,) color each differently. All...
Create 6 tags with text inside them (in a valid HTML page,) color each differently. All show up on the page at this point... it's better to try to have everything upfront and in the open 1st and later have them hide, hover, or whatever interaction they will do. See the video for the text, don't bother matching the colors in the video. Validate the HTML. Bugs multiply as you make the page more complex; a CSS problem could actually...
Use PHP, javascript and a little bit of Html More focus on php Create a logout...
Use PHP, javascript and a little bit of Html More focus on php Create a logout page (for patients) in hotel management. Please provide the screenshot of the output too (logout page). Hint: the logout page should include like this thanks for visting etcetera. Thanks in advance
Please create a PHP action codes for the HTML CODE provided below. <!DOCTYPE html> <html> <head>...
Please create a PHP action codes for the HTML CODE provided below. <!DOCTYPE html> <html> <head> <title> Project for keeping all your input </title> </head> <body> <h1>Welcome to this Web Based Test!!!</h1> <p>Please answer the following questions:</p> <hr/> <form action="" method="post"> Name: <input type="text" name="name" value=""> <font color=red>*</font><br/><br/> E-mail: <input type="text" name="email" value=""> <font color=red>*</font><br> <hr/> Choose your major area of study: <select name="major"> <option value="Digital Media" >Digital Media</option> <option value="Software" >Software</option> <option value="Security" >Security</option> <option value="Business" >Business</option> <option value="Other"...
Create following webpage in HTML : 1. Login Page This is the first page the user...
Create following webpage in HTML : 1. Login Page This is the first page the user should see. The user can login, signup, or continue as a guest. Your task is to implement the following features: a) Signup form This form should collect the information required for creating a new account on your movie database website. At the least, it should collect an email address, username, avatar image/graphic, first name, last name, and a password. You can ask for more...
Develop a one-page website using HTML tags and element to implement the following. THIS IS HEADING...
Develop a one-page website using HTML tags and element to implement the following. THIS IS HEADING 1 THIS IS HEADING 2 THIS IS HEADING 3 THIS IS HEADING 4 THIS IS HEADING 5 THIS IS HEADING 6 THIS IS A PARAGRAPH. THIS IS A PARAGRAPH. THIS IS A PARAGRAPH THIS IS ANOTHER PARAGRAPH. THIS IS ANOTHER PARAGRAPH. THIS IS ANOTHER PARAGRAPH THIS IS A LINE BREAK THIS IS A LINE BREAK THIS IS A LINE BREAK THIS IS AN ORDERED...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT