4: Visibility And Inheritance In OOP PHP | OOP Scopes | Object Oriented PHP Tutorial | PHP Tutorial

Поділитися
Вставка
  • Опубліковано 9 лис 2024

КОМЕНТАРІ • 157

  • @numaanjaved
    @numaanjaved 3 роки тому +41

    you are not including files in the index.php, did you change the hierarchy of files that we don't know about ?

    • @Dani_Krossing
      @Dani_Krossing  3 роки тому +58

      I am including the files 🙂 But I understand the confusion hehe.
      If you look at my line numbers, you can see that "!DOCTYPE" starts on line 4. I included the file at the top, and I just simply scrolled down so you could see the code further down the page. It's just a bad coincidence that I scrolled JUST FAR ENOUGH for the PHP at the top to not be visible hehe.
      I'll go ahead and pin this comment in case others need to know this as well. 😉

    • @numaanjaved
      @numaanjaved 3 роки тому +5

      @@Dani_Krossing thanks sir

    • @razorramont.abaquita2046
      @razorramont.abaquita2046 3 роки тому +5

      @@Dani_Krossing that explains my confusion 🤣 thank you sir.

    • @MHmodAMeerV
      @MHmodAMeerV 2 роки тому

      thank you for asking

  • @samanthadiep
    @samanthadiep Рік тому +3

    I'm going through an intensive training in coding rn and I have really bad ADHD. I had a tough time following any classes but YOU WERE A LIFE SAVER !! You explained everything so clearly in such a short format too. I don't know how I would've done without you. Wishing you the absolute best and can't wait to learn more from you 🔥

  • @Dani_Krossing
    @Dani_Krossing  5 років тому +41

    Hi everyone! Thank you for your patience. I have quite a lot to share and I will list them one by one bellow here :)
    (For anyone who didn't see my message on why I haven't uploaded, it is because my camera has been broken.)
    1.
    I have managed to borrow a working camera temporarily, so for now it is possible to record videos again. Yay! At some point I will need to get my own though hehe.
    2.
    This video you are watching right now is a re-upload! Yes I know it isn't very exciting, but it was one I had laying around :)
    3.
    I have other news I'm excited to share! I have decided to rent an actual office space outside my home, which will be a much better work environment to record videos. Anyone who has experience in working from home can tell you, that "home" isn't always a good work environment because of distractions and limited space. So renting something bigger away from home is a good investment into the future of the channel :) This means (without promising anything) that there could potentially be 1 video a day uploaded to the channel 5 days a week. But not until my office space is ready that is :) The office should be ready around Sept 7th, since I had the opportunity to "customize" the interior of it as it is being renovated for me. I'm excited to see what opportunities this will give me in the future.
    4.
    A month ago I announced that I was re-doing one of my courses in my spare time, and I asked you all what you thought it might be. Most of you were right when you guessed "PHP" :) Again, because of my camera being broken, I also had to "pause" the recordings of those lessons, but I will get around to it again. And NO! The PHP course will not get uploaded periodically and will not delay other uploads from other courses! Once I'm done making the new PHP course, I will upload ALL EPISODES on the same day at the same time! :) This new PHP course will also allow me to make it a MUCH MORE extensive/detailed course than the one currently on my channel.
    5.
    During my little "break" from UA-cam I have had time to pursue other work, and at the same time teach myself new skills which I can later teach on my channel. I am the type of person who loves learning new things, so I have spend my time educating myself :)
    Most of my viewers are still in school according to my analytics, so I hope everyone is having a good vacation! And if you have a job I hope you saved up those juice vacation days to enjoy your summer :)

    • @imyou1166
      @imyou1166 5 років тому

      I payed 10$ on patron for you.. if you please make video on login form with php oop. It will be very helpful.

    • @josefinenoval160
      @josefinenoval160 5 років тому

      Hi, I can't connect to the database. I have seen the first 44 PHP videos. I get a error: Uncaught Error: Call to undefined function mysql_connect() . ($conn, as I called it, like you did).
      The only thing i did not do, was to make a sign-up form, because I don't want everyone being able to get access to my site. And another problem is, I don't know how to Hash my pwd in the database. Hope you can help.
      I consider to make a signup-form, just to register one to two users and there after, delete it or hide the signup-button. Will that work?
      Btw love your videos. Håber virkelig du vil hjælpe mig, ønsker virkelig ikke at give op efter 2 måneders arbejde.

  • @eadrentepish46
    @eadrentepish46 2 роки тому +5

    I really enjoyed this episode. I've been working with Object Oriented PHP for a long time and never knew that this is what it is. your explanations really gave me more understanding about classes.

  • @Nullnummer00
    @Nullnummer00 5 років тому +8

    The best explanation of the difference between protected and private methods/properties I have come across online so far. Thanks!

  • @StarLight-ir9bz
    @StarLight-ir9bz 4 роки тому +11

    Hey Daniel, I had to stop this video halfway to first make my comment. Before I took a very long break, I watched your entire 65 video series on what you now call ‘Procedural PHP’ and you taught it so well. You teach very well, thank you!
    Do not worry about ‘haters’! Some of these similarities you express, are simply metaphors and are very well understood by, I believe, a good number of us. All we need, is to apply deductive reasoning. When you apply a similarity to something, do not worry - you have done your best! There are many other places a brilliant mind can further make reference or research.
    Thumbs up for your good tutorials.... and, oh... do not rush to teach a variety, just because you are being pressured to. Teach what you know well, because you, indeed teach it well. All the best.

    • @tiagomota4734
      @tiagomota4734 Місяць тому

      I watched the video while doing something else, 4 years later CHAT GPT is the way! lol its 1000 times better than any video ever recorded for coding! :)

  • @aesthet1k_
    @aesthet1k_ 4 роки тому

    Daniel, I just want to express how grateful I am that you offer these videos free of charge. I come from a JS background, and despite having bought a course on PHP, I abandoned it because it was absolutely slipshod in its delivery. I found your courses several months back, and haven't looked back since.
    You've helped me develop a solid foundation in the PHP landscape. I'm thankful that you're offering this premium content for free, but I feel I should say I would buy your courses in a heartbeat.
    Keep up the great work, and thank you again!

  • @wellingtonchanda4067
    @wellingtonchanda4067 5 років тому +17

    This is really awesome, if you get stack Add this at the top of the page, index.php => "require_once './includes/person.inc.php';"

    • @VSLComputers
      @VSLComputers 5 років тому

      I noticed that the required file wasn't in his index.php page... so how did it work in the demo?

    • @rasmushansen2391
      @rasmushansen2391 4 роки тому +3

      @@VSLComputers It is in that file, however you're seeing from the 4th line, ergo there's lines above it, including the NAME.inc.php file.

    • @md.immammehadhihossain1644
      @md.immammehadhihossain1644 4 роки тому

      Hi ,can U pls tell me which page I should add that line to get the results and how ?
      Thanks again

    • @tanjimashraf803
      @tanjimashraf803 4 роки тому +1

      @@md.immammehadhihossain1644 add "include includes/person.inc.php" at the top of the index.php file.

    • @almamun.3285
      @almamun.3285 4 роки тому +1

      thank you so much brother...i have been trying if for 6 hours and got the solution...learned to put .. in front of /includes.....

  • @stanislavidalgo3661
    @stanislavidalgo3661 3 роки тому

    you were sent by the PHP God himself. This shit was like an enigma code for three days for me, and here I am 10 minutes, and it's in my system. thanks, dude. you have a talent for teaching man

  • @Parteatime1
    @Parteatime1 Рік тому +1

    Moved to this course from a different PHP course on UA-cam and already I find it so much easier to follow your teaching style. Thank you so much for you content! Also I spent a while thinking you looked familiar and now I realise you look just like a blonde Elon Musk haha

    • @Dani_Krossing
      @Dani_Krossing  Рік тому

      Thank you 😊 I have a much newer “one long video” that teaches OOP PHP 🙂 it’s the most recent upload I believe

  • @cherryyumdiddly
    @cherryyumdiddly 3 роки тому

    I know a lot of other people have already commented the same thing but I have to as well. Thank you for these videos. You do a great job of breaking everything down and explaining each concept and how it implement them. And free access. Thank you sir. Well done.

  • @jessicabakerseuk
    @jessicabakerseuk Рік тому

    minor point
    "$this"
    keyword refers to this instance of the object.
    For those who do not know yet, an object is an instance of a class.
    I guess you said what you did to keep things simple at this stage.
    I know OO from C++ & Java, Im just starting to learn php.
    Thanks, your course so far is very clear for those who have never touched OO, for me Im seeing php lang & looking at syntax, diff keywords etc in php.
    Java insists on 1 class per file, c++ it was optional but considered good practise.
    For those coming from procedural, which I did a long time ago in C we used to use sep files for related groups of functionality. That enabled the whole team to work on the project at the same time and aslo tried to stop the files from becoming so big they were difficult to read.
    Hope this comment helps.
    Best wishes.
    Thank you.

  • @odrisystems4620
    @odrisystems4620 Рік тому

    This keyword "extends" scared me learning java, you made me understand it in such simple explanation

  • @williepietersen4707
    @williepietersen4707 4 роки тому +1

    Thank's Dani so much for this PHP OOP course. It is actually the first time I begin to understand how OOP is working. a Compliment to you!

  • @shivamghai9215
    @shivamghai9215 4 роки тому

    Amazing explanation, nothing too redundant and too tough. Truly a course for the intermediate level programmers and for people who already know a little about OOP but are looking to learn OOP in PHP.

  • @f0ru0l0rd
    @f0ru0l0rd 4 роки тому +1

    You might get hate, but the code says "function." Yes, it's a method, but it's not fair to say it's NOT a function. C++ has issues with this all the time.
    The truth is, it's a function but we call it something different to indicate that it is a function OF an object. Usually, it helps to describe or modify the object, but that's not always the case either.
    Your simplistic explanation was spot on, and perfect! Don't let the haters get you down!

  • @savilboy7269
    @savilboy7269 4 роки тому +1

    The way you deliver the subject is one of the best ones, really appreciate what you do, thank you!

  • @AnotherMaker
    @AnotherMaker Рік тому

    So many people have watched this video that copilot auto completes Daniel Nielson, Age 28. Very nice work :)

  • @fredlegace4431
    @fredlegace4431 3 роки тому

    Hi Dani, thank you for this series. Well thought out and put together.
    When it came to visibility, I wondered why one would choose private over public. You hinted at the reason, but did not clarify it. I did a bit of searching because I need to know "why" before I learn "how".
    A very good reason to make properties private is that you can put all the data checking into the object to ensure data validity. No other object can intrude on that to insert invalid data into the property. Knowing that, the "why" became more obvious. I am sure there are other reasons, but that did it for me.
    I should make all properties private unless I absolutely need to expose them to possible invalid data in order to see the data from outside the object.

  • @monkysonky
    @monkysonky 4 роки тому

    You are one of the best teacher i have seen so far..... Thank you so much..

  • @cebolaloco
    @cebolaloco 4 роки тому

    I'm revisiting you videos cause I find them very useful. Please, give us more PHP content (intermediate to advanced) instead of game videos. That's what your audience is here for. Cheers!

  • @ShannonWhitty
    @ShannonWhitty 3 роки тому +1

    I always had a vague understanding of protected properties but never has it been clearer than now, after watching your video.

  • @naimchowdhury5427
    @naimchowdhury5427 4 роки тому

    Your videos should get at least 25% like from the views. Your way of teaching is so easy to understand!

  • @sloneplace1901
    @sloneplace1901 5 років тому +1

    Thank you. it's clearly understand. already i watched 4 videos. I'll keep watching all videos. .

  • @chandangour6938
    @chandangour6938 4 роки тому

    You are a great instructor. Very easy to understand.

  • @Lyrik-Klinge
    @Lyrik-Klinge 2 роки тому

    Thanks for the very useful tip, not to use the $-sign for the properties and to make clear, that the $-sign is a variable symbol :-)
    Very nice!

  • @yy23pumpkin35
    @yy23pumpkin35 Рік тому +1

    You explanation is just nice. plz making this type of informative videos. thank you. 😊

  • @hoshangkaranjekar4852
    @hoshangkaranjekar4852 4 роки тому +1

    Nice Video Series. It would be great If you can provide a video series from scratch to develop a Live Project like an ERP using OOP's Concept. It would be helpful to clear all small small doubts.

  • @KateFreeland
    @KateFreeland 2 роки тому +1

    Thank you! Your tutorials are great!!!

  • @siavashghasemi7548
    @siavashghasemi7548 5 років тому +2

    u are the best.
    it's so easy to learn with u

  • @ramyadam6280
    @ramyadam6280 4 роки тому

    Great tutorials I am very lucky to have you as my tutor

  • @yassineghouaj292
    @yassineghouaj292 3 роки тому

    you re a big man . thanks from morocco

  • @bernardocampos5908
    @bernardocampos5908 4 роки тому +1

    I love learning PHP with Elon!

  • @PorgyGeorgy1
    @PorgyGeorgy1 4 роки тому

    Is accessing a private property by using a public method kinda like the JavaScript's getters & setters? Oh, and thank you for this video! I've been trough a few other materials that teach PHP, but your explanation is the best. Again, thank you.

  • @alexq3498
    @alexq3498 4 роки тому

    No hate. Just love for the videos. Thanks.

  • @CarolineMiddlebrookUK
    @CarolineMiddlebrookUK 4 роки тому +1

    I love your teaching style :-) I notice that you are using the Atom editor in this one. Can you tell me what Syntax theme you are using?

    • @astratow
      @astratow 4 роки тому

      Looks like Dracula. Use vim please, much better!

  • @rayenab9301
    @rayenab9301 3 роки тому

    Thank you very much , you are a great programming teacher

  • @taher7151
    @taher7151 2 роки тому

    Very good and clear explanation, thanks Sir

  • @HAL-mg4wy
    @HAL-mg4wy 3 роки тому

    Thanks for the tips Mr. Musk.

  • @vanhelsingx69x
    @vanhelsingx69x Рік тому

    Best tutorials and playlist

  • @konstanzefaust9983
    @konstanzefaust9983 3 роки тому

    Thanks for the great videos, they really help me by repeating and adding knowledge to my basic PHP OOP skills in my first job as a programmer.
    What I always wondered in OOP, is why they call it a function in the code when it's not supposed to be a called a function, but a method.
    Wouldn't it have been easier to call it public method Blabla()? ^^'' Just to confuse people, I guess. *lol*

  • @sistemasuniverso1461
    @sistemasuniverso1461 2 роки тому

    que bien explicado. Muchas gracias!!

  • @teddyperera8531
    @teddyperera8531 4 роки тому

    This is a very clear explanation. Thank you

  • @helloimjah
    @helloimjah 4 роки тому +3

    Thank you this was great tutorial!

  • @michaelnovello6629
    @michaelnovello6629 3 роки тому

    Giving this video a thumbs up because you classified a Pet as a Person :)

  • @DariaLinnyk
    @DariaLinnyk 5 місяців тому

    Brilliant video! Thank you!

  • @UnboxTek
    @UnboxTek 5 років тому +1

    thanks for the update, i hope you can add the "dependency injection" tutorials.

  • @freddymuleya3746
    @freddymuleya3746 5 років тому +1

    Hey thank you for the great content, I was wondering can you start an android programming course or recommend another course?

  • @RegressStage
    @RegressStage 4 роки тому +18

    He looks like a mix of Elon Musk & Mr.Beast, interesting...

  • @danielkaniu5948
    @danielkaniu5948 3 роки тому

    Thank you Dani.

  • @mohaddesekm4898
    @mohaddesekm4898 3 роки тому

    this great tutorial is very helpful thank you so much

  • @nonchalant8473
    @nonchalant8473 3 роки тому

    Great tutorials! Thank you

  • @ivnstudios6135
    @ivnstudios6135 4 роки тому

    great tutorial, subscribed to not lose the next videos

  • @newprogrammer1811
    @newprogrammer1811 5 років тому

    As always GREAT CONTENT and thank you.
    you will have more Subscribers if you make Framework Tutorials.

  • @kiransuwal97
    @kiransuwal97 4 роки тому

    Wow, Thank you very much ! I've been trying to learn php on my own but got stuck on class. This video really helped me.

  • @22dgrees
    @22dgrees 5 років тому

    Clearly explained, thank you

  • @hayatzee8830
    @hayatzee8830 2 роки тому

    Thank you.

  • @mohammadshahalam9847
    @mohammadshahalam9847 4 роки тому

    Bro, you are just awesome

  • @win07202
    @win07202 5 років тому

    hello from cambodia

  • @darshmostafa6044
    @darshmostafa6044 3 роки тому

    Hello 🤩 .. Now What's the best Laraval or .Net Core5 ???

  • @cybersec0x004
    @cybersec0x004 4 роки тому

    Great explanation!

  • @JalalNatsheh
    @JalalNatsheh 4 роки тому

    thank you sir

  • @AxxionMarketPlace-iu6ri
    @AxxionMarketPlace-iu6ri Рік тому

    Thank you

  • @Denniskjellin
    @Denniskjellin 2 роки тому

    Great stuff!!!!

  • @paulramura8126
    @paulramura8126 3 роки тому

    Well done!

  • @rifatbeigh1131
    @rifatbeigh1131 4 роки тому

    Amazing.. really helpful.. thankssssss

  • @samduss4193
    @samduss4193 2 роки тому

    Private is only internal CLASS, protected is OK share with family, and public is callable from outside ...so if u call from out side u know u have access only to public at first and then transit lol :) Like a train with customs lol

  • @imyou1166
    @imyou1166 5 років тому +1

    I payed 10$ on patron for you.. if you please make video on login form with php oop. It will be very helpful.

    • @tambovskya
      @tambovskya 5 років тому

      Live YT He has a video on creating a login form with PHP.

  • @rajeshchauhan657
    @rajeshchauhan657 4 роки тому

    awesome ,

  • @brett3554
    @brett3554 3 роки тому +1

    your a natural born orchestrator

  • @karsten7630
    @karsten7630 5 років тому +2

    How were you able to access the class from another php file?

    • @penaltypim5605
      @penaltypim5605 5 років тому +3

      include 'filename'

    • @karsten7630
      @karsten7630 5 років тому +1

      @@penaltypim5605 Was just wondering cause, he doesn't have declare/include in his codes.
      Thanks anyway

  • @gokkulvd9568
    @gokkulvd9568 3 роки тому

    awesome!

  • @anhnguyenhoang8157
    @anhnguyenhoang8157 5 років тому

    thank you so much

  • @ezatullahjunbesh9979
    @ezatullahjunbesh9979 3 роки тому

    Great

  • @prashanthkumar0
    @prashanthkumar0 5 років тому

    great ... php is again 😍😍

  • @ryanleber
    @ryanleber 5 років тому

    Jeez, I was so confused. "In the last video" ... I was like, wait, didn't that last video say 2017?
    Anyway, thanks for these videos, they're super helpful clarifying some things that weren't explained very well in this book I'm reading...

  • @Alexander-ew4dk
    @Alexander-ew4dk 5 років тому

    god video tak :)

  • @pollafattah7062
    @pollafattah7062 3 роки тому

    6:16 The person has an owner!!!! Against this class war we are going to instantiate our objectives .

  • @G3Number
    @G3Number 5 років тому

    Planing on continue on JS?

  • @Born2DoubleUp
    @Born2DoubleUp 2 роки тому +1

    im here 🤓

  • @ahmaddawood9691
    @ahmaddawood9691 5 років тому

    SUPER !

  • @mdmohinulislamsojib6395
    @mdmohinulislamsojib6395 5 років тому

    Waow...
    Sar

  • @salehlodhi3352
    @salehlodhi3352 4 роки тому +11

    after

    • @flophub877
      @flophub877 4 роки тому

      but it's not working for me

    • @D-J-Q
      @D-J-Q 4 роки тому

      @@flophub877
      include ("includes/person.inc.php");

    • @joseulissescastro4883
      @joseulissescastro4883 3 роки тому

      If you are in the root folder, you can try
      include_once("includes/person.inc.php");

    • @learner4166
      @learner4166 3 роки тому

      Thank You Brother!
      But can anyone tell me how his code works without include?
      Just wanted to know..

    • @joseulissescastro4883
      @joseulissescastro4883 3 роки тому

      @@learner4166 Dont think it would work without the includes bro

  • @villastube
    @villastube 5 років тому

    Lovely!!!

  • @patrik5123
    @patrik5123 3 роки тому

    10:00 Caveat: "Person" can not access data from "Pet". So it's not inheriting from one another, per se.

  • @forethiocodingstaff
    @forethiocodingstaff 5 років тому +2

    Please, Python complete tut...

  • @GloriaTortorella
    @GloriaTortorella 4 роки тому

    Coming from PHP this is really confusing but somehow reminds me of Ruby.

  • @privateuser1981
    @privateuser1981 5 років тому

    Class = Object enhanced with "functions", managed "visibility" and "scope". So, why do you care about the haters in comment section?

  • @tanjimashraf803
    @tanjimashraf803 4 роки тому

    00:02:19 - what is the name the " -> " (arrow sign) which was used to call the "owner" function inside of the pet class?

    • @naveenkr5992
      @naveenkr5992 4 роки тому

      I read somewhere it's called arrow construct.

  • @Julio860JVL
    @Julio860JVL 4 роки тому +1

    Another way to explain methods vs functions is, a method is exactly just a function but because it is inside of a class now it is called method.
    function outside a class = function
    function inside a class = method
    method outside a class = function
    method inside a class = method

  • @dan110024
    @dan110024 3 роки тому

    I feel like all these videos are made for me when you use my name in your videos haha

  • @vitdevlab6344
    @vitdevlab6344 4 роки тому

    I was getting Class Pet not found when i tried accessing the the data in the method till i included the Class file in the index.php before i was able to access it. May i know why it worked for you and didnt work for me? or you also included the Class file in the index.php

  • @mondal1839
    @mondal1839 4 роки тому

    I'm the 1000th Liker!

  • @shenannoel3499
    @shenannoel3499 3 роки тому

    Nice Disney princess moves :P

    • @Dani_Krossing
      @Dani_Krossing  3 роки тому

      Thanks! I practiced SO long to get the choreography correct, and finally someone noticed!

  • @geoclaps
    @geoclaps 4 роки тому

    Thank you very much for the great video! Really enjoying the explanation regarding visibility. Did not see the first 3 lines on the index.php wich probably include the person.inc.php file :)

  • @ayushsatyam2616
    @ayushsatyam2616 4 роки тому +1

    Thanks Elon Musk for teaching me php

  • @bobz2169
    @bobz2169 Рік тому

    4:39

  • @ReyAngeles
    @ReyAngeles 4 роки тому

    how do I return multiple values? I've tried using return array($a,$b,$c); However I get an error ": Array to string conversion" The only way I was able to output anything was by doing a print_r($entity->getentity());

  • @nomcebomakhos
    @nomcebomakhos 3 роки тому

    If i am given scenarios like this ,how to run it and for exam im not allowed to use a compiler What advice can you give
    function calculate($arr, &$num){
    $result = 0;
    foreach($arr as $value){
    $result += $value;
    }
    $num = $result / 2;
    }
    $arr = array(0,2,4,6,8);
    $num = 0;
    calculate($arr,$num);
    echo $num;

  • @localLyricsPh
    @localLyricsPh Рік тому

    wondering how to include? Here example -> "" or "" just add above the "!DOCTYPE". but guys remember the path depends on what is the file structure of your folder.