Aims:
true
and false
valuesNULL
''
, ' '
,
'a'
, 'Hello world!'
,
"Hello world!"
, '1109'
,...
$a = 3; $b = 4.5; $c = "plip"; $d = 3.0; $e = 6 + 7; $f = 6 - $a; $g = $e * $f; $h = 2 + 1.5; $i = $a + $b; $j = 6 / 2; $k = 6 / 4; $l = 6 / 2.0; $m = $c . ' plop'; $n = "{$c} plop"; $o = "three"; $p = "3"; $q = '3.0';
college_form.html
contains this form:
<form action="college_ratio.php" method="get"> <input type="text" name="num_of_students" value="0" /> <input type="text" name="num_of_staff" value="0" /> <input type="submit" /> </form>
<input type="number" />
because browser
support is too limited at present)
college_ratio.php
, which computes and echoes the
number of students per staff member
$num_of_students = $_GET['num_of_students']; $num_of_staff = $_GET['num_of_staff'];
num_of_students
) and
4 (num_of_staff
)
$_GET['num_of_students']
contains '100'
, not 100$num_of_students
will also contain '100'
, and will
be of type string
<input type="number" />
)
(int)
to request type conversion to integer from, e.g., string
(float)
to request type conversion to float from, e.g., string
$num_of_students = (int) $_GET['num_of_students']; $num_of_staff = (int) $_GET['num_of_staff'];
$num_of_students
?
$num_of_students = (int) $_GET['num_of_students']; $num_of_staff = (int) $_GET['num_of_staff']; $num_of_students_per_staff = $num_of_students / $num_of_staff; echo '<p>'; echo $num_of_students_per_staff; echo '</p>';
journey_form.html
contains this form:
<form action="total_journey.php" method="get"> <input type="text" name="distance" value="0.0" /> <input type="text" name="num_of_trips" value="0" /> <input type="submit" /> </form>
total_journey.php
which calculates and outputs
the total distance (km) that the student travels
int qty = 7; qty = "Hello, world!";The second statement gives rise to a fatal error message at compile-time
$qty = 7; $qty = "Hello world!";The second statement gives rise to no error message nor warning message