Basic PHP Syntax - PHP 8 Tutorial

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 12. 06. 2024
  • 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
    ⭐ Become a Patreon: / programwithgio
    THANK YOU!
    LESSON 1.2
    Course Outline - github.com/ggelashvili/learnp...
    Course Playlist - ‱ Learn PHP The Right Wa...
    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

Komentáƙe • 163

  • @user-ei8yw1nd5n
    @user-ei8yw1nd5n Pƙed rokem +11

    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.

  • @alexsavastru8125
    @alexsavastru8125 Pƙed rokem +26

    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!

    • @ProgramWithGio
      @ProgramWithGio  Pƙed rokem +7

      Thank you & send my thanks to your mentors, really appreciate it 💙

    • @keshiiiiii
      @keshiiiiii Pƙed rokem +2

      Same đŸ€­

  • @lynic-0091
    @lynic-0091 Pƙed 2 lety +10

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

  • @SynMlyn
    @SynMlyn Pƙed 4 měsĂ­ci +2

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

  • @user-zh2oz9fe4m
    @user-zh2oz9fe4m Pƙed 10 měsĂ­ci +4

    Learning PHP language is very pleasant thanks to this channel.

  • @michaligocki35
    @michaligocki35 Pƙed 3 lety +9

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

  • @kewl-asian
    @kewl-asian Pƙed rokem +7

    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 :)

    • @ProgramWithGio
      @ProgramWithGio  Pƙed rokem +1

      Glad you like it, welcome aboard 🙌🙌

  • @a7medalyousofi
    @a7medalyousofi Pƙed 2 lety +2

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

  • @rustlejack9542
    @rustlejack9542 Pƙed 2 lety +2

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

    • @ProgramWithGio
      @ProgramWithGio  Pƙed 2 lety

      Thank you, I'm glad that you like my tutorials 🙌

  • @MehdiEm
    @MehdiEm Pƙed 2 lety +8

    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

    • @ProgramWithGio
      @ProgramWithGio  Pƙed 2 lety

      Thank you. I spend a lot of time preparing videos, I don't know everything by heart :)

  • @SarahPoulin
    @SarahPoulin Pƙed rokem +1

    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!!!

    • @ProgramWithGio
      @ProgramWithGio  Pƙed rokem +1

      It's one of the reasons why I made this course and put in so much effort. Glad you like it and find it useful, feel free to ask any questions as you are going through the course 🙌

  • @cristianvulpe1408
    @cristianvulpe1408 Pƙed 3 lety +5

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

  • @jonkoenig2478
    @jonkoenig2478 Pƙed 3 lety +2

    Good to see new content coming out, PHP is still my favorite language. Just feels good to me, not sure why!

    • @ProgramWithGio
      @ProgramWithGio  Pƙed 3 lety

      PHP is great and it is my favorite language as well. Not only because it pays the bills but also because of the community & its huge ecosystem. PHP is constantly being improved & updated & is just great to work with.

  • @davidarnold1881
    @davidarnold1881 Pƙed rokem

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

  • @jibinjoseph5228
    @jibinjoseph5228 Pƙed 3 lety

    Very clear explanation you deserve more audience.
    You earned a new subscriber.
    Keep up the good work 😍😍

  • @aow6813
    @aow6813 Pƙed rokem

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

  • @ahmadyounis6814
    @ahmadyounis6814 Pƙed 7 měsĂ­ci

    Perfect explanation 👌

  • @gazianis7572
    @gazianis7572 Pƙed 2 lety +9

    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 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
    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.

  • @snakemanluffy7645
    @snakemanluffy7645 Pƙed 3 lety +1

    Thanks. I didn't know about the reference. Looking forward to finish this amazing course :P

  • @tvnisa6035
    @tvnisa6035 Pƙed rokem

    very good, i'm wathching from Brazil, thank you.....congratulations for your channel!

    • @ProgramWithGio
      @ProgramWithGio  Pƙed rokem +1

      Thank you & greetings to you my friend, love Brazil (my favorite national football team)

  • @mazadesigndev295
    @mazadesigndev295 Pƙed 3 lety +4

    Once again, very clear and nicely explained. Plus, I enjoyed learning the concepts that are not very widely taught in other resources. keep it up! :)

  • @mahmoudshabakat2974
    @mahmoudshabakat2974 Pƙed 2 lety

    thank you very much for this excellent course.

  • @victorpinasarnault9135
    @victorpinasarnault9135 Pƙed 3 lety +1

    Real Nice!
    Liked and subscribed.

  • @knowlife4486
    @knowlife4486 Pƙed rokem

    Thank you for your great contribution !!

  • @khonsmail7675
    @khonsmail7675 Pƙed rokem

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

  • @SoniaChavez-je7hq
    @SoniaChavez-je7hq Pƙed 4 měsĂ­ci

    Very helpful tutorial ❀

  • @GeneralStaal
    @GeneralStaal Pƙed 7 měsĂ­ci

    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.

  • @cryptoknight7256
    @cryptoknight7256 Pƙed rokem

    Excellent! Thanks, Gio!

  • @FaresKhalid
    @FaresKhalid Pƙed 2 lety

    very powerful tutorial :)

  • @k.bharathkempula6896
    @k.bharathkempula6896 Pƙed rokem

    very clear explanation sir

  • @migueldemaria3830
    @migueldemaria3830 Pƙed 3 lety +1

    learning lots of cool little details here!

  • @AhmedShehtaShe7ta
    @AhmedShehtaShe7ta Pƙed 3 lety +1

    Keep up the good work. ❀

  • @Islam.our.religion
    @Islam.our.religion Pƙed rokem

    Thx for the great video

  • @user-vq7ry8hr6d
    @user-vq7ry8hr6d Pƙed 5 měsĂ­ci

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

  • @ballpen9157
    @ballpen9157 Pƙed rokem

    great. thank you.

  • @leonardohirsch9086
    @leonardohirsch9086 Pƙed rokem

    great tutorial. Thanks

  • @tahamohamed2161
    @tahamohamed2161 Pƙed 9 měsĂ­ci

    U are the best ❀

  • @JacS975
    @JacS975 Pƙed 11 měsĂ­ci

    thank you again

  • @ahmedyasser571
    @ahmedyasser571 Pƙed 2 měsĂ­ci

    thank you so much

  • @stefanbirsan3320
    @stefanbirsan3320 Pƙed 2 lety +1

    great!

  • @bibekbasnet4698
    @bibekbasnet4698 Pƙed rokem

    i have started learning it i will come back when i finish it! 😄

  • @gomeypublic
    @gomeypublic Pƙed rokem

    finally i found a good PHP course.

  • @ilya_123__
    @ilya_123__ Pƙed 9 měsĂ­ci

    thank you

  • @Cantin91
    @Cantin91 Pƙed rokem

    Awesome :)

  • @zonegamma8197
    @zonegamma8197 Pƙed 2 měsĂ­ci

    thanks a lot

  • @faisalasif5986
    @faisalasif5986 Pƙed 2 lety

    Great Master

  • @sujanmiya4514
    @sujanmiya4514 Pƙed 2 lety

    Realy cool

  • @PrzyjacielKamil
    @PrzyjacielKamil Pƙed 2 lety

    Good for beginners.

  • @alnahian2003
    @alnahian2003 Pƙed rokem +2

    Wow! I just learned that in PHP variables are assigned by value by default and not by reference 😼
    Already seeing some progress, can't wait for more 🎉

  • @vladimirputindreadlockrast812
    @vladimirputindreadlockrast812 Pƙed 11 měsĂ­ci

    You can also use a period to concatenate a string: $s = "Hello " . "World";

  • @954roof
    @954roof Pƙed 9 měsĂ­ci

    Working on a laravel project and struggling with syntax hope this will help

  • @user-Des3
    @user-Des3 Pƙed 3 měsĂ­ci

    Hi, there. I am absolutely new in this. I have already installed VSC, is it ok for php? You didn't recommended in the video...

    • @ProgramWithGio
      @ProgramWithGio  Pƙed 3 měsĂ­ci

      It's fine, I don't use VSC, I use phpstorm but a lot of devs use vscode & I think its fine. It just may not have all the features phpstorm has.

  • @user-vk4qk7db9e
    @user-vk4qk7db9e Pƙed 5 měsĂ­ci

    can i use vs code as IDE while following ur tutorial?
    beginner here thank you

  • @chriscentproductions6905
    @chriscentproductions6905 Pƙed 9 měsĂ­ci

    How did you make the browser auto update the output of the code?

  • @user-oq2cx2lv8o
    @user-oq2cx2lv8o Pƙed 9 měsĂ­ci

    Hello ,pleasehow can i fix the port problem definitly in xampp,cause all the time i open xampp i have to change port number

    • @ProgramWithGio
      @ProgramWithGio  Pƙed 9 měsĂ­ci

      Maybe something else is running on that port that is holding it up?

  • @susantc5288
    @susantc5288 Pƙed 2 lety

    Is there a reference that gives us a list of course in order of the video names?

    • @ProgramWithGio
      @ProgramWithGio  Pƙed 2 lety

      Yes, the link to the repo is in the description. It contains outline of all videos with title and link

  • @emmanuelterdoomzer6309
    @emmanuelterdoomzer6309 Pƙed 8 měsĂ­ci

    Can you please confirm that the link to your patreon account works? I hit the url but it seems to be broken or something.

    • @ProgramWithGio
      @ProgramWithGio  Pƙed 8 měsĂ­ci

      Yes works fine on my end, just tested it as well

  • @chibuikeemenike6377
    @chibuikeemenike6377 Pƙed rokem

    pls which text editor is suitable to code php

  • @fractal4157
    @fractal4157 Pƙed 2 lety

    How to make errors to appear in a browser? I've edited php.ini file and set error_reporting = E_ALL and display_error = On, but nothing changed. The program is still crashes silently.

  • @llamallama7
    @llamallama7 Pƙed 6 měsĂ­ci

    Many jobs opportunities using PHP from where I am located. I was learning Node.js and I will still practice it but I feel like I should learn PHP and not pay attention to those who say that PHP is dead.

    • @ProgramWithGio
      @ProgramWithGio  Pƙed 6 měsĂ­ci

      Thats a good strategy, you should go based on demand & if in your location PHP is on demand then it makes sense to learn PHP

  • @olisaisama7083
    @olisaisama7083 Pƙed 10 měsĂ­ci

    Hi Gio. Nice videos. I created php functions to be used to generate dynamic html but i feel is the wrong practice. I watched your videos on slim and twig but couldnt wrap my head around so im using php template for the view rendering. Is there a way i can use slim php with React (acting as the dynamically generated html for the views) where if render view eg home.php with some fetched db data the React takes the $data which I'd json encode in the home.php view and pass it as a prop to a React component to dynamic generate the views. In short how can i merge slim php with react

    • @ProgramWithGio
      @ProgramWithGio  Pƙed 10 měsĂ­ci

      You can use PHP with React but you would need to use PHP as an API layer and pass data to your react via ajax calls. Its a bit complicated to set it up but its certainly possible. You can look into Inertia.js for Laravel which allows you to pass down to react components directly from controllers similar to how you would pass it down to regular views

    • @olisaisama7083
      @olisaisama7083 Pƙed 9 měsĂ­ci

      @@ProgramWithGio this is great! Thank you, mate.

  • @augischadiegils.5109
    @augischadiegils.5109 Pƙed 2 lety

    ❀❀❀❀❀

  • @rosarioveneruso9928
    @rosarioveneruso9928 Pƙed rokem

    Hi Gio, one thing about the semicolon, I saw in following videos that when you declare function or classes you don't use the semicolon at the end, why that? Isn't it an end of a statement?Indeed if I put it in those occasions it seems that the script doesn't work, I'm quite confused.

    • @ProgramWithGio
      @ProgramWithGio  Pƙed rokem

      Hey, you don't need semicolon at the end of }. Can you point me to timestamp on the video on what part you are referring to? You don't need semicolon on single line expressions like this

    • @rosarioveneruso9928
      @rosarioveneruso9928 Pƙed rokem

      @@ProgramWithGio
      I didn't mean u put semicolon at the end of }, I was askin' why is that in general.
      "Hey, you don't need semicolon at the end of }" --->why is that? I can't understand where to put semicolons exactly.
      I meant that in following videos of yours there were (indeed) no semicolon at the end of } but I cannot understand why if we're saying that we must put them after every statement.
      There were something like this(but also seeing other codes):

    • @ProgramWithGio
      @ProgramWithGio  Pƙed rokem

      @@rosarioveneruso9928 } on its own is not a statement so yea you don't put a semicolon there. It's just a closing bracket. If that were case then you would need to put semicolon at the end of each line including the if() {.
      P.S. I don't think the above code is from my lesson.

    • @rosarioveneruso9928
      @rosarioveneruso9928 Pƙed rokem

      @@ProgramWithGio It isn't , i was just an example(i wrote "somethin' like"), the point was that it wasn't clear to me when/where put semicolon.
      "} on its own is not a statement so yea you don't put a semicolon there" I meant the two brackets with what is inside of it, don't we count that as a statement? The block inside of it is not a/a series of instruction/s?

    • @ProgramWithGio
      @ProgramWithGio  Pƙed rokem +1

      @@rosarioveneruso9928 I would watch lesson about expressions in this series, it might help. You just don't put semicolons at the end of brackets, idk if there is a list of things that you can't put semicolons on but that's one of them. Whatever is contained within control block (within brackets) at the end of those lines you put semicolon, they are usually expressions.

  • @arthurmunhoz7095
    @arthurmunhoz7095 Pƙed rokem

    Joel Karr to be fair I learnt loads

    • @ProgramWithGio
      @ProgramWithGio  Pƙed rokem

      Was this directed to me or someone else? Either way, thank you 💙

  • @Neceros
    @Neceros Pƙed rokem +1

    holy shit you went with php storm. Great software but expensive as heck and probably not something a new user would invest in.

    • @ProgramWithGio
      @ProgramWithGio  Pƙed rokem +1

      Sure, you can use whatever IDE you want, phpstorm is not a requirement. It's just what I use and am comfortable with

  • @lisalin9375
    @lisalin9375 Pƙed rokem +1

    Hi I am a completely beginner for PHP, but the tutorial is really too fast for me :( a bit frustrated

    • @ProgramWithGio
      @ProgramWithGio  Pƙed rokem

      Hello. You can slow it down by clicking on the ⚙ icon and set playback speed to 0.75x or 0.5x. I apologize if it's too fast, I've made some editing mistakes where I cut out all empty spaces.

  • @teacupentertaining6073
    @teacupentertaining6073 Pƙed rokem

    Srry boys but echo ("Hello {$variable}") is deprecated since php 8 so if you are searching why vscode gives u a warning in this line of code now you know why

    • @ProgramWithGio
      @ProgramWithGio  Pƙed rokem +1

      Nope, that is not deprecated in PHP 8 and is perfectly valid. Did you define the variable? What error are you getting? Maybe you are referring to PHP 8.2 which deprecates this: "${variable}" but "{$variable}" should still work

    • @teacupentertaining6073
      @teacupentertaining6073 Pƙed rokem

      @@ProgramWithGio works but vscode says it's deprecated since php 8

    • @ProgramWithGio
      @ProgramWithGio  Pƙed rokem

      @@teacupentertaining6073 I don't see it in the php documentation as being deprecated. You can see here what's deprecated in 8.2: www.php.net/manual/en/migration82.deprecated.php

  • @AlexeySuzdalenko
    @AlexeySuzdalenko Pƙed 5 měsĂ­ci

    i am study inglish language in this video

  • @CharlesPlaysIQ
    @CharlesPlaysIQ Pƙed 10 měsĂ­ci +1

    wcan i get like to the creator of this video,im learning php anow, im am lat?

    • @ProgramWithGio
      @ProgramWithGio  Pƙed 10 měsĂ­ci

      I'm the creator of the video, what's up?

  • @limittendstoinfinity
    @limittendstoinfinity Pƙed 3 měsĂ­ci

    how to free use PHPStorm lifetime?

  • @almoemason
    @almoemason Pƙed 9 měsĂ­ci

    I was a bit confused at first until I realized that you do not know the meaning of the symbol quotes in English. ' = apostrophe, " = quotes and "" = double quotes.

    • @ProgramWithGio
      @ProgramWithGio  Pƙed 9 měsĂ­ci

      Thanks, English isn't my first language, but in PHP we usually call it all quotes (single, double) and saying apostrophe usually confuses people more since most know it as "quotes" and either single or double quote works in most cases.

  • @BlackCrypt
    @BlackCrypt Pƙed rokem

    Php8?

    • @ProgramWithGio
      @ProgramWithGio  Pƙed rokem +1

      Yup, we upgrade to PHP 8, & to 8.1 in following videos. At the time of recording of this video 8.0 wasn't released yet.

  • @moofymoo
    @moofymoo Pƙed 10 dny

    echo print('!!');

  • @thechoosen4240
    @thechoosen4240 Pƙed 8 měsĂ­ci +1

    Good job bro, JESUS IS COMING BACK VERY SOON; WATCH AND PREPARE

  • @user-hp4bx3gn6k
    @user-hp4bx3gn6k Pƙed 2 lety

    Ⴤართველი ჟარ ჼო ? დ

    • @ProgramWithGio
      @ProgramWithGio  Pƙed 2 lety

      კი 🙂

    • @user-hp4bx3gn6k
      @user-hp4bx3gn6k Pƙed 2 lety

      @@ProgramWithGio აჄáƒȘენჱზე გეჱყობა დდ
      პ.ქ. მჹვენიერი კაი áƒĄáƒáƒ„áƒ›áƒ”áƒ, ისე áƒ„áƒáƒ áƒ—áƒŁáƒšáƒáƒ“áƒáƒȘ რო დადო გამოგვადგება ბევრ დამწყებს

    • @ProgramWithGio
      @ProgramWithGio  Pƙed 2 lety +1

      @@user-hp4bx3gn6k მადლობა. áƒ„áƒáƒ áƒ—áƒŁáƒšáƒáƒ“ გამიჭირდება რადგან áƒ„áƒáƒ áƒ—áƒŁáƒšáƒáƒ“ არ áƒ›áƒáƒ„áƒ•áƒĄ ნასწავლი მე თვითონ 🙂.

  • @paulhughes8907
    @paulhughes8907 Pƙed 8 měsĂ­ci

    hard to follow examples, your screen is too small

    • @ProgramWithGio
      @ProgramWithGio  Pƙed 8 měsĂ­ci

      Yea, I realized that a bit late. In section 3 it gets better since I zoom in a bit and also I zoom in on parts that are important.

  • @younickbongo7870
    @younickbongo7870 Pƙed 2 lety +1

    you know what you don't deserve???? a dislike. nice video.

  • @motiv8street
    @motiv8street Pƙed 3 měsĂ­ci

    Thanks a lot