This repository was archived by the owner on Aug 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvariables.php
93 lines (73 loc) · 1.9 KB
/
variables.php
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<h1>
<?php
echo "hello World";
// this is a single line comment
# Single line comment
/*
Multiline
comment
*/
# VARIABLES
/*
- Prefix $
- Start with a letter or an underscore
- Only letters, numbers and underscores
- Case sensitive
*/
# DATA TYPES
/*
String
Integers
Floats
Booleans
Arrays
Objects
NULL
Resource
*/
$output = 'Hello Fahim!';
echo $output;
$num1 = 5;
echo $num1;
$floatValue = 2.5;
echo $floatValue;
$booleanValue = true;
$anotherBool = False;
echo $booleanValue;
echo $anotherBool;
$number1 = 20;
$number2 = 40;
$sum = $number1 + $number2;
echo $sum;
# String concatenation
$string1 = "Miles";
$string2 = "Morales";
$completeString = $string1 . $string2;
echo $completeString;
// adding a space between them
$fullString = $string1 . ' ' . $string2;
echo $fullString;
// easier way
$easierWay = '$string1 $string2'; // it prints exactly what is there in the single quotes. $string1 $string2
echo $easierWay;
// If I want to print the value for the variables, I need to use the double qoutes
$perfectEasierWay = "$string1 $string2";
echo $perfectEasierWay; // Miles Morales
# Escape sequences
$string3 = 'They\'re here!';
echo $string3; // They're here!
$string4 = "They're here!";
echo $string4; // They're here!
// but
$string5 = "He said, \"Hey Fahim!\".";
echo $string5; // He said, "Hey Fahim!".
# CONSTANT
define('GREETING', 'Hello, everyone!');
echo GREETING; // not echo $GREETING. $ must not be used in constant.
// making a constant case insensitive
/* it is deprecated
define('GREETING2', 'Hello greeting 2', true);
echo greeting2;
*/
?>
</h1>