-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02_variables.php
45 lines (39 loc) · 1.19 KB
/
02_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
<?php
/* ----- Variables & Data Types ----- */
/* --------- PHP Data Types --------- */
/*
- String - A string is a series of characters surrounded by quotes
- Integer - Whole numbers
- Float - Decimal numbers
- Boolean - true or false
- Array - An array is a special variable, which can hold more than one value
- Object - A class
- NULL - Empty variable
- Resource - A special variable that holds a resource
*/
/* --------- Variable Rules --------- */
/*
- Variables must be prefixed with $
- Variables must start with a letter or the underscore character
- variables can't start with a number
- Variables can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
- Variables are case-sensitive ($name and $NAME are two different variables)
*/
$name = 'Stefan'; // string
$age = 20; // int
$has_drivers_license = true; // boolean
$cash_on_hand = 50.50; // float
// echo "$name is $age years old";
// echo $name . ' is ' . $age . ' years old';
// echo "<br>";
// var_dump($has_drivers_license);
// var_dump($cash_on_hand);
$x = '5' + '5'; // 10
// var_dump($x);
// echo 10 - 5;
// echo 10 * 5;
// echo 10 / 5;
// echo 10 % 5; // 0
define('HOST', 'localhost');
define('USER', 'root');
echo HOST;