Question

Write PHP that does the following: Creates 4 variables, with values “My”, “Name”, “is”, “Bill”. Concatenates...

  1. Write PHP that does the following:
    1. Creates 4 variables, with values “My”, “Name”, “is”, “Bill”.
    2. Concatenates all 4 variables using the concatenation operator, while adding a space between each one and assigns the result of the concatenation into a 5th variable named $stringCatResult.
    3. Display the $stringCatResult value using an echo statement.
  1. Write PHP that does the following:
  1. Creates 2 variables, with values 12 and 3
  2. Write five separate lines of code that performs an arithmetic operation on the 2 variables.
  • Addition
  • Subtraction (with a positive result)
  • Division
  • Multiplication
  • Modulus

After performing the arithmetic operation, write code that displays the resulting value of each arithmetic operation without an additional variable using an echo statement.

  1. Write PHP that does the following:
  1. Creates 5 variables, with values “A”, “Fine”, “Time”, “To Learn”, PHP”.
  2. Write PHP code that displays each variable in a single HTML TABLE.
    Please build the table using the concatenation operator.
    Please display each word above in a row, making the HTML TABLE a 1 column 5 ROW HTML TABLE.

A

Fine

Time

To Learn

PHP

  1. Write PHP that does the following:
  1. Creates 6 variables, with values “A”, “Fine”, “Time”, “To”, “Learn”, PHP”.
  2. Write PHP code that displays each variable in a single HTML TABLE.
    Please display each word above in a row, making the HTML TABLE a 2 column 3 ROW HTML TABLE.

A

Fine

Time

To

Learn

PHP

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I have written the PHP code for your problem and added explaination in comments wherever needed.

for additional information, you may refer : w3schools website

Below is the Code:

<html>
<head>
<!-- This is internal CSS to add good looks to tables.-->
<style>
table {
border: 1px solid black;
border-spacing: 0px;
padding: 0px;
}
td {
border: 1px solid black;
padding: 3px;
}
</style>
</head>
<body>
<?php
//Write PHP that does the following:
//Creates 4 variables, with values “My”, “Name”, “is”, “Bill”.
$variable1 = "My";
$variable2 = "Name";
$variable3 = "is";
$variable4 = "Bill";
//Concatenates all 4 variables using the concatenation operator, while adding a space between each one and assigns the result of the concatenation into a 5th variable named $stringCatResult.
$stringCatResult = $variable1 . " " . $variable2 . " " . $variable3 . " " . $variable4;
//Display the $stringCatResult value using an echo statement.
echo $stringCatResult;
echo "<br>"; // to add line break
//Write PHP that does the following:
//Creates 2 variables, with values 12 and 3
$num1 = 12;
$num2 = 3;
//Write five separate lines of code that performs an arithmetic operation on the 2 variables.
//Addition
$addition = $num1 + $num2;
//Subtraction (with a positive result)
$subtraction = $num1 - $num2;
//Division
$division = $num1 / $num2;
//Multiplication
$multiple = $num1 * $num2;
//Modulus
$modulus = $num1 % $num2;
//After performing the arithmetic operation, write code that displays the resulting value of each arithmetic operation without an additional variable using an echo statement.
// <br> is html tag for the new line.
echo '<br> Addition = ' . ($num1 + $num2);
echo '<br> Subtraction = ' . ($num1 - $num2);
echo '<br> Division = ' . ($num1 / $num2);
echo '<br> Multiplication = ' . ($num1 * $num2);
echo '<br> Modulus = ' . ($num1 % $num2);
echo '<br><br>'; // this is line break to separate output.
//Write PHP that does the following:
//Creates 5 variables, with values “A”, “Fine”, “Time”, “To Learn”, PHP”.
$var1 = "A";
$var2 = "Fine";
$var3 = "Time";
$var4 = "To Learn";
$var5 = "PHP";
//Write PHP code that displays each variable in a single HTML TABLE.
//Please build the table using the concatenation operator.
echo '<table><tr><td>' . $var1 . $var2 . $var3 . $var4 . $var5 . '</td></tr></table>';
echo '<br>'; // this is line break to separate tables.
//Please display each word above in a row, making the HTML TABLE a 1 column 5 ROW HTML TABLE.
echo '<table><tr><td>' . $var1 . '</td></tr>' . '<tr><td>' . $var2 . '</td></tr>' . '<tr><td>' . $var3 . '</td></tr>' . '<tr><td>' . $var4 . '</td></tr>' . '<tr><td>' . $var5 . '</td></tr></table>';
//Write PHP that does the following:
//Creates 6 variables, with values “A”, “Fine”, “Time”, “To”, “Learn”, PHP”.
$word1 = "A";
$word2 = "Fine";
$word3 = "Time";
$word4 = "To";
$word5 = "Learn";
$word6 = "PHP";
echo '<br>'; // this is line break to separate tables.
//Write PHP code that displays each variable in a single HTML TABLE.
echo '<table><tr><td>' . $word1 . '</td></tr></table><br>';
echo '<table><tr><td>' . $word2 . '</td></tr></table><br>';
echo '<table><tr><td>' . $word3 . '</td></tr></table><br>';
echo '<table><tr><td>' . $word4 . '</td></tr></table><br>';
echo '<table><tr><td>' . $word5 . '</td></tr></table><br>';
echo '<table><tr><td>' . $word6 . '</td></tr></table><br>';
//Please display each word above in a row, making the HTML TABLE a 2 column 3 ROW HTML TABLE.
//For this, i am using php inside the HTML tags
?>
<table>
<tr><td><?php echo $word1; ?></td><td><?php echo $word2; ?></td></tr>
<tr><td><?php echo $word3; ?></td><td><?php echo $word4; ?></td></tr>
<tr><td><?php echo $word5; ?></td><td><?php echo $word6; ?></td></tr>
</table>
</body>
</html>

Add a comment
Know the answer?
Add Answer to:
Write PHP that does the following: Creates 4 variables, with values “My”, “Name”, “is”, “Bill”. Concatenates...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please code in c 1. Write a program which does the following: Declare and initialize three...

    Please code in c 1. Write a program which does the following: Declare and initialize three pointers. One points to an integer, one points to a float and one points to a character variable Ask the user to enter appropriate values for these variables. Output the values to the screen by accessing the variables directly and then by using pointer references. Print the address of each variable. Modify the variables by performing any arithmetic operation only using pointer refer- ences...

  • Variables lab Write a program that creates three variables: an int, a double, and a String. Put the value 113 into t...

    Variables lab Write a program that creates three variables: an int, a double, and a String. Put the value 113 into the first variable, the value .71828 into the second, and the value Computer Science" into the third. It does not matter what you call the variables... this time. Then, display the values of these three variables on the screen, one per line. This is room # 113 e is close to 2.71828 I am learning a bit about Computer...

  • 1. Print out information of PHP use phpinfo() function. 2. Write a program that check and...

    1. Print out information of PHP use phpinfo() function. 2. Write a program that check and print odd / even numbers (from number 1 to 100 using for/while loop). Display the results within an HTML table with 2 columns as shown below: NUMBERS RESULTS 1 ODD 2 EVEN 3 ODD HINT: use <table> tags to create a table, <th> tags for ‘Numbers’ and ‘Results’. Wrap code PHP inside HTML code. For example: ​<html> ​​<title>CHECK ODD or EVEN</title> ​​<body> ​​​<table> ​​​​<?php...

  • Q1. rewrite the exercise on April 4 by adding the following operations: 1) In the php...

    Q1. rewrite the exercise on April 4 by adding the following operations: 1) In the php script, create an associative array named $order that stores the following values: - the number of cheese toppings; - the number of pepperoni toppings; - the number of ham toppings; - the size of the ordered pizza; - the number of the ordered pizza; - the total cost of the order; - the discount rate; - the total cost after the discount. 2) the...

  • 1.C++ Write a program that uses a structure named MovieData to store the following information about...

    1.C++ Write a program that uses a structure named MovieData to store the following information about a movie: title, director, year released, and running time (in minutes). Include a constructor that allows all four of these member data values to be specified at the time a MovieData variable is created. Your program should do the followings: A. creates two MovieData variables (namely, movie1 and movie2) B. creates two pointers to the structure MovieData (namely, movie1Ptr and movie2Ptr) and initializes them...

  • Explain the code: Exercise 22: Write a program that creates three random double variables a, b,...

    Explain the code: Exercise 22: Write a program that creates three random double variables a, b, and c and assigns them values between 0 and 1 using the Math.random( ) method mentioned in the preceding exercise. It then does all of the following: It prints out the three values. It prints "All are tiny" if all three values are less than 0.5. It prints out "One is tiny" if exactly one of the three values is less than 0.5. It...

  • Using C++, Write a class named Employee that has the following member variables: name. A string...

    Using C++, Write a class named Employee that has the following member variables: name. A string that holds the employee's name. idNumber. An int variable that holds the employee's ID number. department. A string that holds the name of the department where the employee works. position. A string that holds the employee's job title. The class should have the following constructors: A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee's name,...

  • Write a PHP program using a ''FOR loop' to compute and print the employee's salary for...

    Write a PHP program using a ''FOR loop' to compute and print the employee's salary for some number of years with a percent increase each year. Your submit button should re-call this page and use PHP to create a table of salaries for each year starting at 1 up to the value of the years variable. So if 'years' is equal to 5, there should be 5 rows in your table. For each year, the salary increases by X%. Make...

  • Using Java, write a program that creates a class to represent what you spend your time...

    Using Java, write a program that creates a class to represent what you spend your time on every week. Inside of that class, you will need a 2D array that represents each day of the week and how much time you spend on any given activity (the size should be 7 by whatever the number of activities you perform in a week). You may enter the values however you like, but you will need to display the array so that...

  • (b) Write a JavaScript function that displays the 216 web safe colours with their hex values in a 36 × 6 table. In an R...

    (b) Write a JavaScript function that displays the 216 web safe colours with their hex values in a 36 × 6 table. In an RGB colour model, assigning each of the Red, Green, Blue components with a value from [00, 33, 66, 99, CC, FF] will create a web safe colour, for example, #3366FF Use the DOM methods createElement ) and appendChild() to write the function. Working code using other DOM methods may receive partial marks <html> head> <title>Web Safe...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT