-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.php
More file actions
50 lines (45 loc) · 1.2 KB
/
variables.php
File metadata and controls
50 lines (45 loc) · 1.2 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
<?php
// 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
/*
Sring
Integers
floats
Boolean
Arrays
Objects
NULL
Resource //function
*/
$output = "So close to achieving it!";
$num1 = 4;
$num2 = 10;
$sum = $num1 + $num2;
$string1 = 'Hello';
$string2 = 'World';
$greeting = $string1 .' '. $string2.'!'; //conacatenation
$greeting2 = "$string1 $string2"; //stings with single quote will display correctly in a double quote
#escape sequences
$string3 = 'They\'re Here';
$string3 = "They're Here";
$string3 = "They\"re Here";
#constants
define('GREETING', 'Hello Everyone'); //a constant takes two parameters: name(always in uppercase) and the value of the constant(always in quote)
define('GREETING', 'Hello Everyone', true); //constants are case sensitive by default, set the third parameter to true to make them case insensitive
$float1 = 4.4;
$bool1 = true;
echo $greeting2;
echo GREETING; //calling a constant has to be exactly the way it was declared(in capital). They are case sensitive by default
?>