Register|Login

Have a question? Click here to ask the community.

Tutorial 11 – If Statements

| In: 11. If Statements | 9,520 views

Video Tutorial


Video Source Code
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
<?php
//File Description: PHP If Statements
/*
if (THIS CONDITION IS TRUE ) { //then
    DO THIS    
}
 
*/
 
// Example 1
 
$userAge = 10; // contains the person's age
$validAge = 18; //the valid age to display content
 
if ($userAge < $validAge) {
    echo "You are not old enough to view this content <br>";
}
echo "Welcome to The PHP Basics <br>";
 
 
// Example 2
 
$userName = "Robert2"; // contains the person's name
 
if ($userName == "Robert") {
    echo "Hello $userName <br>";
}
 
?>

Comment Form

You must be logged in to post a comment.