Basic PHP Syntax - PHP 8 Tutorial

preview_player
Показать описание
Let's write some PHP & go over the basic syntax. After this video, you will be able to concatenate & print text to the browser, declare & use variables, use variables within strings & embed PHP within HTML. In all of my videos, I cover a lot of small details that in my opinion are very important so I recommend watching the video fully.

SOME OF THE WAYS YOU CAN SUPPORT THE CHANNEL
👍 Smash the like button
🤝 Subscribe to the channel & turn the notifications on
💬 Post comments, any feedback is greatly appreciated
THANK YOU!

LESSON 1.2

CHAPTERS
00:00 Intro
00:41 Basic Syntax
01:58 Hello World
03:22 Run PHP In Terminal
03:50 Print vs Echo
05:18 Escaping Quotes
05:45 Variables
06:26 $this variable
06:48 Assigning by Value vs Reference
07:45 Variables Within Text
08:52 PHP In HTML
10:45 Comments
Рекомендации по теме
Комментарии
Автор

I highly recommend this video on the Basics of PHP Syntax to total beginners and anyone who lacks a clear starting point, as it is truly helpful.

ZoricaStojicic-nv
Автор

Well, considering I'm currently in an internship and trying to catch up to my mentors, this series is an absolute gold mine. One of my mentors recommended it and I couldn't be more satisfied by it. Thank you for the invaluable work you put into this!

alexsavastru
Автор

Learning PHP language is very pleasant thanks to this channel.

Vitalii-mr
Автор

Huge thanks to Gio for the invaluable knowledge shared in these tutorials!

SynMlyn
Автор

This will help out beginners immensely, I wish I had these basics when I just started, would've helped me out a lot!

lynic-
Автор

These are legit the best coding practices I have ever learned, and you just tackled printing and variables. I'm commited to finish this tutorial :)

kewl-asian
Автор

lots of great stuff, very detailed. you're the best PHP teacher I've ever encountered.

michaligocki
Автор

This is the third tutorial I'm on, and I had to quit the other two (which are supposedly for beginners), because of deprecated code and no fix for the problems. One thing I wondered was why there was no php closing tag used. Nobody ever explained it. You are the FIRST to actually explain why! Thank you!!!

SarahPoulin
Автор

The best explanation way I have ever attended on Youtube, a lot of information that I did not find in another youtube channel, I really like your way of explanation.

Thank you, Gio.

amedalyousofi
Автор

Wow ... the amount of information you have is insane!!! It shows that you really know what you are talking about. Thanks for this valuable series! :D

MehdiEm
Автор

I have been developing in PHP for some years . . . and didn't know about ONLY have an opening PHP tag, for files that ONLY contain PHP. A great tutorial.

GeneralStaal
Автор

Hey Gio! You deserve Millions of Subscribers. Keep it up and bring more courses like this 'cause I'm really enjoying this course.

rustlejack
Автор

I like how you speak slowly and explain everything . I will complete the full course .. Keep up the good work

aow
Автор

That's awesome, I really love your teaching style. Keep up the good work.

cristianvulpe
Автор

Very Clear. I liked your introduction and how detailed you are. Starting right at the beginning is frustrating but absolutely necessary as you say

davidarnold
Автор

ur the person we need buut dont deserve

saikumar-cdzz
Автор

TNice tutorials comnt from you is legendary. Uncomplicated like your video!!!

khonsmail
Автор

php file:

If you want your file to be interpreted as php then your file must end with that php and not with that html. php files can also have html, CSS, JavaScript in them.

php tag:

php opening and closing tag is <?php ?> and php interpreter interpreted the code between opening and closing tag. But if your file entirely contain 100 percent php code then you do not need the closing tag and that is to make sure that no accidental whitespace or new lines are added after the php closing tag which could mess up your website.



Semicolon:

php closing tag will automatically assume the semicolon on the last line.
So basically you do not need semicolon the Last line of php statement. This is useful when you are embedding php with html and it's just a single line in those case s you do not need the semicolon but if you have multiple lines though it's a good idea to stay consistent and just use the semicolon.

php code execute:
You could execute your php script within your terminal. If you open xampp control panel and click on shell on here this will bring up the terminal. We need to cd into our project directory which is htdocs program with project name and then you could run php files using the php command and that will give you the output. So you could basically execute your php code in command line if you want.

You could also use print to print something which essentially is the same thing as echo.

Difference of echo and print:
Print has a return value of 1 for that reason here I give an example like
<?= print "hello world" ?>
I do echo and then print that will print out hello world and then append one at the end because this expression itself return 1 this means that print could be used within expressions while echo can not for example if we did this the other way print echo "hello world" and this would not work and we would get the syntax error.
Echo could print multiple values while print can not.
for example
echo "abc", "xyz";//works
print "abc", "xyz";//does not works
Echo is marginally faster than print.

variable
Vraible declared with dollar sign($).First character start with a-zA-Z_ and then other character from a-zA-Z_0-9.No space and no special character are allowed. This is a object so you do not assign $this.

Variables in php are by default assign by value .Let me show you what I mean
so if we have a variable called x which equals to 1and then we have a variable y which equals o x and then we change the value of x to 3 and then we print y what will be printed is 1 and not 3 that is because variables are assigned by value.On the other handif you actually wanted y to change whatever x cahnges then we need to assign variables by reference instead of value. Assign a variable by reference, you need to add ampersand righ here so now y is equal to reference variable x so anytime x cahnges the y will also change and now y is equal to 3.

Comments:
There are two types of single line comments that are // your comments and #your comments.
Multiline comments is /* comment here */. Nested multiple comments are not allowed.

gazianis
Автор

learning lots of cool little details here!

migueldemaria
Автор

Thank you for this wonderful and very knowledgeable 🙏 PHP learning series.

DHADUKPARASKUMAR