- The following is a test code for fun:
<html> Anything between the HTML tags will be displayed by the browser.<br>
<?php
echo ("Here comes my PHP code. It also shows on the browser.<br>");
print "Right now, I start learing PHP.<br>";
print "I will become an expert by the end of the summer.<br>";
?>
</html> |
What is above <br>? What does it do?
- Now, I am going to make some changes. The code looks like the following:
<html> Anything between the HTML tags will be displayed by the browser.<br>
<?php
echo ("Here comes my PHP code. It also shows on the browser.<br>");
print "Right now, I start learing PHP.<br>";
print "I will become an expert by the end of the summer.<br>";
</html> |
Is the above code still working? Why?
- Now, is the following code working? Why?
<html> Anything between the HTML tags will be displayed by the browser.<br>
<?php
echo ("Here comes my PHP code. It also shows on the browser.<br>");
print "Right now, I start learing PHP.<br>"
print "I will become an expert by the end of the summer.<br>";
?>
</html> |
- Now, is the following code working? Why?
<html> Anything between the HTML tags will be displayed by the browser.<br>
<?php
Echo ("Here comes my PHP code. It also shows on the browser.<br>");
Print "Right now, I start learing PHP.<br>";
Print "I will become an expert by the end of the summer.<br>";)
?>
</html> |
Hint for the upcoming test: There is one statement that has problem(s). I will ask you to provide a complete and correct statement to replace the incorrect one. Exact spelling and case are required as they are in real code.
- If I want comment out the echo statement of the code on question 1, how do I do it?
- The following code does not generate any syntax error. However, the result is incorrect.
<?php
//The following code was written to compare two variables
$myFirstVariable=20.1;
$mySecondVariable=30;
if ($myFirstVariable=$mySecondVariable)
{
print "My fist variable equals to my second variable<br>";
print "My first variable is ".$myFirstVariable."<br>";
print "My second variable is ".$mySecondVariable."<br>";
}
else
{
print "My fist variable does NOT equal to my second variable<br>";
print "My first variable is".$myFirstVariable."<br>";
print "My second variable is".$mySecondVariable."<br>";
}
?>
|
What is wrong with my above code? You may have to refer to Chapter 4 for an answer.
- I have one variable named $variable1 and I have to define it as double precision data type. The value of the variable is 25. What is the correct statement to declare the variable?
- What will be the output for the following code? Why?
<?Php
$myVar=(int) 2.5555;
print $myVar;
?> |
- What will be the output if I can change the definition statement of question 8 into: $myVar=(bool) 2.5555?
- What will be the output if I can change the definition statement of question 8 into: $myVar=(float) 2.5555?
|