WEBVTT

00:00.230 --> 00:05.480
So before we start any coding, let's get something out of the way first.

00:06.110 --> 00:15.800
So PHP code is stored inside files with the PHP extension, but you can't just write PHP right away

00:15.800 --> 00:18.140
inside the PHP file.

00:19.040 --> 00:22.520
You actually need a PHP starting tag.

00:22.520 --> 00:28.070
And if you mix PHP with HTML, you also need a closing tag.

00:28.100 --> 00:36.350
You can add multiple of those opening and closing tags inside such document where you can put the PHP

00:36.350 --> 00:37.190
code.

00:37.220 --> 00:41.780
So PHP code actually needs this starting tag all the time.

00:41.780 --> 00:50.300
Even if a file contains only PHP code, that's different from languages like JavaScript or Ruby, where

00:50.300 --> 00:52.880
you can just write code straight away.

00:52.910 --> 00:59.660
Now, in PHP, every statement requires a semicolon at the end.

00:59.690 --> 01:07.220
That's also different with languages like JavaScript, for example, where the semicolon is optional,

01:07.250 --> 01:10.970
or Python where there is no semicolon at all.

01:10.970 --> 01:13.460
You use tabs instead.

01:13.490 --> 01:18.590
So the semicolon is required always, except around the braces.

01:18.590 --> 01:23.990
So if you have an if statement like this, for example the semicolon is not required here.

01:24.290 --> 01:26.000
Now there are some exceptions.

01:26.000 --> 01:33.470
For example when you have this declaration that is telling PHP to use strict types, you don't need

01:33.470 --> 01:34.370
a semicolon here.

01:34.370 --> 01:41.570
You also don't need a semicolon after a namespace declarations, though you can still use it, so it's

01:41.570 --> 01:49.190
easier to just remember to use it at all times except after curly braces.
