-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3. what is echo and print.php
More file actions
66 lines (49 loc) · 1.63 KB
/
Copy path3. what is echo and print.php
File metadata and controls
66 lines (49 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
// Used echo show the output
// Can output multiple values separated by use , comma
// Does not return a value
// Can be used with or without parentheses
// speed Generally faster
// echo used in function
// The echo statement can be used with or without parentheses: echo or echo().
echo "Hello";
//same as:
// echo used in function
echo ("Hello");
// Used echo show the output multi value
echo "Hello ", "dalveer ", "singh <br> ";
// variables with the echo
$txt1 = "Learn PHP";
$txt2 = "W3Schools.com";
echo "<h2>$txt1</h2>";
echo "<p>Study PHP at $txt2</p>";
// using single quotes, variables have to be inserted using the . operator,
$txt1 = "Learning PHP";
$txt2 = "operator";
echo '<h2>' . $txt1 . '</h2>';
echo '<p>Study PHP at ' . $txt2 . '</p>';
//************************************************************************************************************************** */
// Print
// Can only output a single value.
// Always returns a value 1.
// speed slower than
// Can be used with or without parentheses.
// statement can be used with or without parentheses: print or print().
print "Hello";
//same as
// print used in function
print("Hello");
// print command notice that the text can contain HTML
print "<h2>PHP is Fun!</h2>";
print "Hello world!<br>";
print "I'm about to learn PHP!";
// shows to output Used variables with the print
$txt1 = "Learn";
$txt2 = "PHP";
print "<h2>$txt1</h2>";
print "<p>Study PHP at $txt2</p>";
// When using single quotes, variables have to be inserted using the . operator,
$txt1 = "Learning";
$txt2 = "php oop";
print '<h2>' . $txt1 . '</h2>';
print '<p>Study PHP at ' . $txt2 . '</p>';