forked from assembler-institute/php-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprint.php
More file actions
45 lines (27 loc) · 1.22 KB
/
Copy pathprint.php
File metadata and controls
45 lines (27 loc) · 1.22 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
<?php
//Instruction that makes use of "echo"
echo "This is a test with echo.", "\n", "<br>"; // "\n" means line feed (avance de línea)
echo 'This ', 'string ', 'was ', 'made ', 'with multiple parameters.', "\n", "<br>";
echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . "\n" . "<br>"; // . is used to concatenate
echo "Hello ", isset($name) ? $name : "Pau Tomás", "!" , "<br>";
$example = "The argument can be any expression";
echo "$example which produces a string", "<br>";
$sports = ["tenis", "padel", "football", "basketball"];
echo "My favourite sports are " . implode(", ", $sports) . "..." . "<br>"; // implode — Join array elements with a string
echo 3 * 12;
echo "<hr>";
//Instruction that makes ude of "print"
print "This is a test with print. <br>";
$example = "The argument can be any expression";
print "$example which produces a string <br>";
$sports = ["tenis", "padel", "football", "basketball"];
print implode(", ", $sports);
print "<br>";
print 6 * 7;
print "<hr>";
//Instruction that makes use of "print_r" — Prints human-readable information about a variable
echo "<pre>";
$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
print_r ($a);
echo "</pre>";
?>