Practical program exercise 8 PHP Create & Execute Echo and Print Statements for 12th computer applications
PHP Create & Execute Echo and Print Statements
echo
- The echo statement produce output fast
- It doesn’t return any value
- The echo statement produces one or more lines of output.
- The echo statement is missing the closing quotation mark.
- The instructions in this instance consisted of a call to PHP’s echo statement, which is responsible for displaying output to the user; the output to be displayed is enclosed in quotation marks.
- The print statement produce output slow
- It return the value 1
variable
- A variable is simply a container that’s used to store both numeric and non-numeric information.
- And just as with any container, you can move it from place to place, add stuff to it, or empty it out on the floor in a pile and fill it with something completely different.
Assigning Values to Variables
- Assigning a value to a variable in PHP is quite easy: use the equality (=) symbol, which also happens to be PHP’s assignment operator.
- This assigns the value on the right side of the equation to the variable on the left.
- PHP has some simple rules for naming variables.
- Every variable name must be preceded with a dollar ($) symbol and must begin with a letter or underscore character, optionally followed by more letters, numbers, or underscore characters.
- Common punctuation characters, such as commas, quotation marks, or periods, are not permitted in variable names; neither are spaces.
CA – 8 PHP – CREATE & EXECUTE ECHO AND PRINT STATEMENTS
QUESTION:
- Write a PHP code to demonstrate the usage of echo and print in PHP.
AIM:
- To create and execute ECHO and PRINT statements in PHP program.
PROCEDURE:
1. Start Xampp server (Apache)
2. Go to virtual path folder (C:\xampp\htdocs)
3. Create test.php file and type the program
4. Execute the program on your Web browser using by this URL link (http://localhost/test.php)
PROGRAM:
<html>
<body>
<?php
echo “Welcome to Tamilnadu <br>”;
print “Welcome to our School!<br>***********”;
$txt1 = “Learn PHP”;
$txt2 = “Daily”;
$x = 5;
$y = 4;
echo “<h2>” . $txt1 . “</h2>”;
echo “Study PHP “.$txt2.”<br>”;
echo $x + $y;
$txt3 = “Hello”;
$txt4 = “Welcome”;
$x = 7;
$y = 3;
print “<h2>”.$txt3.”</h2>”;
print “Hi “.$txt4.”<br>”;
print $x + $y;
?>
</body>
</html>
OUTPUT:
Welcome to Tamilnadu
Welcome to our School!
***********
Learn PHP
Study PHP Daily
9
Hello
Hi Welcome
10
RESULT:
The Output was verified successfully