Setup and syntax
Run PHP from the terminal and learn variables, types, output and strict mode.
What you will be able to do
- Start PHP code with the opening tag and end it only when mixing HTML.
- Use declare(strict_types=1) at the top of every file.
- Prefer single quotes when you do not need interpolation.
- Inspect values with var_dump while developing.
In plain English
PHP runs on the server and sends finished HTML to the browser. A file starts in HTML mode and switches into PHP with an opening tag. Strict types turn accidental string-to-number coercion into visible errors, which is exactly what you want while learning.
<?php
declare(strict_types=1);
$name = 'Ada';
$score = 91.5;
$active = true;
echo "Hello, {$name}! Score: {$score}\n";
var_dump($active);Your turn
EasyPrint a formatted line
Create variables for a course title and a lesson count, then print "CSS has 16 lessons" using interpolation.
PHP · starter
<?php
$title = 'CSS';
$lessons = 16;
// print the lineCheck your understanding before moving on.
Knowledge checkQuestion 1
What does declare(strict_types=1) change?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.