- Declare variables cName, thisIsAName, q45D and number to be of type int.
| |
- Display a message asking the user to enter an integer.
| |
- Print the message "This is a program" on one line in the command window.
| |
- Print the message "This is a program" on two lines in the command window where the first line ends with a. Use only one statement.
| |
- State that a program will calculate the product of three integers.
| |
- Declare the variables x, y, z and result to be of type int.
| |
- Declare the variables xVal, yVal and zVal to be of type String.
| |
- Prompt the user to enter the first value, read the value from the user and store it in the variable x.
| |
- Prompt the user to enter the second value, read the value from the user and store it in the variable y.
| |
- Prompt the user to enter the third value, read the value from the user and store it in the variable z.
| |
- Assign x to variable xVal.
| |
- Assign y to variable yVal.
| |
- Assign z to variable zVal.
| |
- Assign zero to variable result.
| |
- Compute the product of the three integers contained in variables x, y and z, and assign the result to the variable result.
| |
- Display a dialog "The product is " followed by the value of the variable result.
| |
- Concatenate greeting and your-name in a one line.
| |
- Count the length of variable x where in x is an input from the user.
| |
- Display hello word
| |
- Count and display the length of “ simple greeting.”
| |
I. Synthesis.Write php statements to accomplish each of the following: (3 pts each; 60 pts)
II. Write the output of the following code fragment. 20 pts
1. <?php $person = 'George'; echo '\tHello\n$person!!'; ?> | |
2. <?php echo 'Hello World!'; ?> | |
3. <?php $Greeting = 'Hello World!'; ?> <?php echo $Greeting; ?> | |
4. <?php
$greeting = $_GET['greet']; ?> <?php echo "$greeting World!"; ?> | |
5. <?php $person = "George"; echo "\tHello\n$person!!"; ?> | |
III. Explain the following. (10 pts each:20 pts)
- There's two commands to start writing PHP code. <? and <?php - Which one is preferred, and why?
- Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/atomicoz/test.php on line 5
Here's the code that produced the error
for ($i=0; $i<5; ++$i)
{
echo $i
}
0 Comments