Low cost ecommerce web development India flash website design
Important
Remember to type the double-equals, because if you were to use a single
equals sign you'd be using the assignment operator discussed above. So,
instead of comparing the variable to the designated value, instead, you'd
assign a new value to the variable (an operation which, incidentally,
evaluates as true). This would not only cause the condition always to be
true, but might also change the value in the variable you're checking,
which could cause all sorts of problems.
60
Getting Started with PHP
Conditions can be more complex than a single comparison for equality. Recall
that we modified welcome1.php to take a first and last name. If we wanted to
display a special message only for a particular person, we'd have to check the
values of both names (welcome6.php):
$firstname = $_REQUEST['firstname'];
$lastname = $_REQUEST['lastname'];
if ( $firstname == 'Kevin' and $lastname == 'Yank' ) {
echo( 'Welcome, oh glorious leader!' );
} else {
echo( "Welcome to my Website, $firstname $lastname!" );
}
This condition will be true if and only if $firstname has a value of Kevin and
$lastname has a value of Yank. The word and in the above condition makes the
whole condition true only if both of the comparisons evaluate to true. Another
such operator is or, which makes the whole condition true if one or both of two
simple conditions are true. If you're more familiar with the JavaScript or C forms
of these operators (&& and || for and and or respectively), they work in PHP as
well.
website designer freelance ASP PHP ecommerce web developer
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110