B02 — Data that tells a story: variables and types
Basic level · Lesson B02
B02 — Data that tells a story: variables and types

Result: an educational resource sheet with coherent data.
Central concept: each data has meaning and type.
Guideline time: 60–90 minutes.
Is “5”, 5 and true the same thing?
No. Although they may look similar, they represent text, a number, and a logical state. Choosing the right type avoids strange calculations and hard-to-understand rules.
Previous connection
In B01 we use name, goal and hours. Now we will distinguish string, int, float, bool and null.
Concepts
string: text, such as a title.int: integer, such as 12 sessions.float: decimal, such as 1.5 hours.bool:trueorfalse.null: intentional absence of a value.
Type is not decoration: it determines which operations make sense.
Guided laboratory
<?php
$title = "Introducción a PHP";
$sessions = 6;
$hoursPerSession = 1.5;
$available = true;
$certificateDate = null;
echo "Curso: $title<br>";
echo "Horas totales: " . ($sessions * $hoursPerSession) . "<br>";
echo $available ? "Disponible" : "Cerrado";
Use var_dump($sessions); during scanning to observe value and type; remove it from the final presentation.
Medium Mission
Create a file for a fictitious club or workshop with six variables and at least four types. Explain why a quantity should not be stored as text.
University Extension
Try strict comparisons between 5 and "5". Documents the output of == and ===, explains the risk of implicit conversions, and proposes consistent variable names.
Tests
- Change availability between
trueandfalse. - Use zero sessions.
- Check the types with
var_dump.
Delivery
Send code, capture, variable-type-reason table and a question. SEND TO TUTOR.

Comments
Post a Comment