Database design: keys, relationships and normalization
Design tables that avoid duplicated data: primary keys, foreign keys, one-to-many and many-to-many relationships.
Store values in variables and learn the five types you will use every day.
A PHP variable starts with $ and has no declared type. PHP decides the type from the value.
<?php
$name = 'Ali'; // string
$age = 30; // integer
$price = 19.99; // float
$ok = true; // boolean
$list = [1, 2, 3]; // arrayvar_dump($age); // int(30)
echo gettype($price); // doubleUse . to join strings, or put variables inside double quotes:
echo 'Hello ' . $name . '!';
echo "Hello $name, you are $age years old.";'$name' in single quotes prints the text $name, not the value."5" + 3 gives 8, because PHP converts the string. Add declare(strict_types=1); at the top of a file to get errors instead of silent conversion in function calls.$Name and $name are different.Make variables for your name, age and city, then print one sentence that uses all three.
Design tables that avoid duplicated data: primary keys, foreign keys, one-to-many and many-to-many relationships.
A folder layout and a few habits that keep a growing PHP site tidy, secure and easy to maintain.