11: First exercise in OOP PHP | OOP PHP Exercise | Object Oriented PHP Tutorial | PHP Tutorial

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

КОМЕНТАРІ • 194

  • @sweotsmc9085
    @sweotsmc9085 5 років тому +15

    Since 2015 and you are still making PHP video. That is such dedication. Love to you Daniel

  • @StoneUSA
    @StoneUSA 4 роки тому +27

    There was one thing in this lesson that I think might confuse people just starting out. It isn't normal to link directly to an include file from a form like this. The include file will not contain any of the HTML from the view (index.php in this case) and so when you submit your form the output will be missing things like your title, styles or other controls and content you have on the page. So instead what we do is link the form back to the view and add a conditional statement in index.php that reads if(isset($_POST['submit'])) include('includes/calc.inc.php'); This includes the calculator into the current view but only when the form has been submitted. Anyway, great video. Great series. There's always more to learn.

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

      Thank you!

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

      I feel like i get you but I don't. I'm confused lol. Anyway to contact you?

    • @PmkooOfficial
      @PmkooOfficial 9 місяців тому +1

      @@hearvie The point is, after user submit the form, all provided data goes to calc.inc.php using POST method. In this situation we are leaving calculator form forever :P because after calculation is done, the result is gonna be seen in calc.inc.php page after using echo. I understand that Dani did it just to show some practice example how to use classes, methods and properties but in real app, we should send the result back to form page and show it to the user. But now I think that @phyternl explained it much better than me so sorry if I confused you.

  • @OJeyjunior
    @OJeyjunior 3 роки тому +2

    everyone talking about how good his lessons are... nobody talking about how handsome he's lookin' in this episode, the guy putting the extra effort for us, congrats m8

  • @MrDeano2506
    @MrDeano2506 4 роки тому +20

    Mate you're an absolute legend. I love your tutorials. You're so thorough and easy to follow. Thank you and please keep them coming.

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

    Put all the pieces together and I was able to create a signup form using the MVC model. Honestly so thankful for your tutorials. Thank you!

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

    As I go through your course, I express my gratitude, like and comment ' thank you' on each video.

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

    I am watching this video from Japan! and I am totally big fan of this guy right here!!! thank you for all of your lessons that helps me a lots!!

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

    You're the best teacher ever, thank you so much I going to watch the entire course because I want to be an expert php programmer also.

  • @sohaibrahman6240
    @sohaibrahman6240 3 роки тому +10

    In my opinion, Calc should be renamed as Calculator. And the method calculator should be renamed as calculate. It is as per the "nice to have" convention that class should be named as Noun since it represents an object/thing and method should be named as a Verb since it represents an action that an object performs.

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

    Learned oops so many times but applied it the first time in some useful way. Thanks, Dani

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

    What an awesome video series! You make it much easier to understand not just what we're doing but why we're doing it! Great Job!!

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

    This is a super helpful series for those of us learning PHP. It would be great to see more in-depth real-world examples of how to deploy OOP PHP for web development, on tasks such as user authentication, password recovery, user account dashboards, shopping carts, etc. Thank you for everything that you're doing!

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

      I tried making that, and I must say that what Daniel is doing is very VERY difficult. Making real-world example AND tech concepts is even more challanging, it is almost not worth the time. I have one tutorial like you describe it, and I am only at the very beginning after several hours and episodes

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

    You really saved my lab assignment!!! I have never found any other videos that have enough example step by step like yours. Thank you seriously! :-)

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

    May i rant a little bit about the Tutorial? Hope people wont hate me.
    In PHP we have PSR standards, if you follow PSR-4 Autoloading you can easily implement external libraries within your code, so rather creating a file with .class i would follow the standard. You could use PSR-0 even it is deprecated.
    In your calc.inc.php you have a closing php Tag, according to the PSR-2, the closing tag tag MUST be omitted from files containing only PHP.
    You class i would rather call "Calculator" and the Method i would call "calculate" instead of switch case i would create private methods and use call_user_func_array to call the methods with a method_exists check before.
    Following defined standards is a good thing in my opinion, since all the Frameworks and Companies out there are following them, so if you know them early, it will be easier for you to work in a company/team.

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

      @@RameenFallschirmjager no books just phptherightway.com and do project and ask on stack overflow. Don't just read. Solve your problems

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

      @@RameenFallschirmjager actually the projects finds YOU;) start with your personal homepage/blog. solve YOUR problems

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

      @@RameenFallschirmjager in 2000 we used to have a Guestbook on our webpage, create a guestbook with administration backend where you can edit entries

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

      Completely agree with your points about defined standards. Using call_user_func_array instead of switch is a matter of didactics, I personally wouldn't use that in this video, it's just a bridge too far for most people. I have to say that I find the use of an include file inside an action tag very peculiar, though.

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

    Please make more videos, sir! I greatly enjoy your videos, very beginner friendly, very detailed and your chill attitude makes it looks like you enjoy it. I like the whole thing in general, I wrote a vbs bot to watch the shortest video in the list for 20 times, many thanks!

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

    Hey Dani, I think your tutorials are great. I‘ve been following them for many years now.

  • @johnniep
    @johnniep 4 роки тому +6

    You could skip the need for the If statement altogether by using
    $path = __DIR__ . '/../classes/';
    (double underscores around the DIR)
    It refers to a path in relation to the location of the class-autoload.inc.php file

  • @mojamals
    @mojamals 4 роки тому +9

    Nice, thanks - Fix an error in class.autoload.inc.php - in the last line:
    require_once strtolower($path . $className . $extention);

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

    you know that the most important thinks that i have learned in your courses is how to manage your code you know class folder includes folder so thank you very much

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

    You just save my life 🙂, I feel very emotional right now 😭, do you have any tutorial on REST API, please I need that

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

    Yo! Man, I love you so much. I have been trying to get a hang of OOP for quite a while now, but most youtube tutorial suck at explaining the concept well. You Just killed it bro.... I now understand the topic.
    Can you do a tutorial on PHP framework Yii

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

    Great tut, Daniel! :)
    That leather jacket suits you very well! 👌

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

    Great video, Daniel! You are the best PHP-instructor on youtube:D Also, I liked the "Switch"-Joke haha

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

    I've heard your Nintendo joke for the third time now and it really just gets more and more funny each time

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

    You don't really need that else statement on $path. Just declare it values before the if :) Either way, great vid ^^

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

    thank you for your video tutorials and you rock that leather jacket coz u look super cool in it! keep up the good work!

  • @predraggrbic2266
    @predraggrbic2266 4 роки тому +2

    Is it a good idea and practice to add "calculator" method inside __construct, and thus shorten the code inside calc.inc.php? Also, your explanations are simple and great!

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

    very simple and very clean thank you

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

    You deserve more views!!! Your lessons are great. Keep it up

  • @alisamiller9600
    @alisamiller9600 3 роки тому +2

    If you run this under Linux, make sure your class names (e.g., Calc) and file names (e.g., Calc.inc.php) use same cases. In this example, calc.inc.php won't work, as Unix-based systems are case-sensitive by default.

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

    excelent teacher good 100%

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

    subtle flex on the leather jacket? hahaha good video!

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

    Great video series, really engaging and easy to follow, thank you!

  • @woodzeppelin3241
    @woodzeppelin3241 3 місяці тому

    These videos are very good. I got it now, or getting it.

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

    Nice jacket. You should put some heavy metal music in the background this time!

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

    omg, i have learned a lot of oops here, thanks Dannii

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

    Thanks, really nice simple projekt

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

    Daniel, you my angel of knowledge, thanks alot:)

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

    Well, good lesson. You could have written the Calc class better by using private attributes instead of public and editing switch by returning the result variable at the end of the function to avoid to repeat the code many times...

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

      I completely agree, that would improve this video. 🙂 I always cringe when watching my past coding convention. 😅 Luckily I don't have them today.

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

    Love the look of the new office!😂

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

    Thank you for the lessons.

  • @PankajKumar-gt3ld
    @PankajKumar-gt3ld 4 роки тому +1

    Just one word, awesome.

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

    9:09 Oper.
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
    >rator
    by the way, love your tuts, man

  • @90sClubAnime
    @90sClubAnime 2 роки тому

    Great Tutorial !!

  • @rashedulhasan5372
    @rashedulhasan5372 4 роки тому +2

    @mmtuts : hi, just a bit of confusion. you included class-autoload.inc.php in both index.php and calc.inc.php file. Do we really need the class files to be included in index? aren't we using the classes just in our calc.inc.php file?

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

    Thank you

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

    thanks for your videos Daniel

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

    Pls make more exercise a practical one that we can use them inside our website ❤ love ur tutorials

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

      just adapt and use the code you learned

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

    Hi, Dani. Thank you a lot for your video. I hope you still answer questions on the topic.
    Towards the end of the video you said that the correct design pattern is to split class, execution and presentation code.
    I want to place the result so that the calculator can be used again immediately without the need of going back.
    Without AJAX, i must place the execution of the class in the presentation file, correct?
    Is it better to place the result in a $_SESSION global, redirect and then pull the result in the index page?

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

    Get rid of that Microphone :)
    Anyway, nice to see you in Action again and wish you success!

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

      Nah, the sound is amazing, keep the mic.

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

      @@dejangegic it's just a Taste. That was my opinion! You can write yours and not answer to mine...

  • @faroukassim4447
    @faroukassim4447 8 місяців тому

    0:20 "This is my new office in case you didn't know" (proceeds to remove the background)

  • @pixels-tutorial
    @pixels-tutorial 3 роки тому

    Really helpful...

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

    Great explained for beginners!

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

    Ooh, your leather jacket is cool!

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

    honestly, i really laughed with your Nintendo switch joke :))

  • @infosandfacts7536
    @infosandfacts7536 4 роки тому +4

    the if condition in the autloader could be simpler:
    $path = "classes/";
    if (strpos($url, 'includes')) {
    $path = "../classes/";
    }

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

    subscribed at the cool leather jacket moment

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

    I just love this dude :)

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

    Thanks so much for this video. its really Helpful. Do you mind creating a series with Laravel or send me the link if you already have one?

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

    New jacket + new office! !!!

  • @user-bi7nq4nj7q
    @user-bi7nq4nj7q 3 роки тому +1

    I spent 2 hours troubleshooting the issue where it differs that you are using a case-insensitive OS. Can we recommend your next lessons be performed on a more industry standard OS? like Linux? Macos? None of the companies my friend are getting hired for are using windows os. Its frustrating when I think its your autoloader, but instead its a conflict caused by you capitalizing the class name. I apologize for the frustrated tone, your classes have been invaluable in learning OOP - Ive been learning how to debug, and getting in some good debug exp, which is definitely a required skill!

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

      Do you have any documentation to prove that PHP classes and functions are different on different OS? 🙂
      I know that some path naming might be different on different OS, but it seems very odd to me that the coding language itself changes.
      Would love to know if that’s the case. 🙂 But to answer the question, no I won’t be teaching the different variants if you are right about the OS, since I don’t have a Mac or Linux to test it out on. But honestly… in my 7 years I haven’t heard about the issue you are describing 😅

    • @user-bi7nq4nj7q
      @user-bi7nq4nj7q 3 роки тому +1

      @@Dani_Krossing Thank you for your quick response! My debugging output was failing at two places initially: unable to find calc.inc.php and unable to find class “Calc”
      After placing echo all over the place in class-autoload.inc.php and directly including class-autoload.inc.php in calc.inc.php i was able to witness the autoloader’s mistake. I changed the class and its references in all files to “calc” and everything worked flawlessly. This worked for me, added right after the $className variable was assigned within the function myAutoLoader:
      function myAutoLoader ($className) {
      strtolower ($className);
      $url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

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

      No problem 🙂 Well, from glancing your code it seems your code isn’t like I taught in my “auto load tutorial”.
      In your code, you included a “strtolower()”, which is why your code can’t find the class in your autoload function, because you tell it to search for a lowercase class name. 🙂
      So it isn’t a OS issue from what I can see, which seemed odd to me when you told me about it hehe.
      It is common practice to name your classes with a uppercase letter, so if I were you I would change my class name back and make sure your autoload looks like the one I showed in my tutorial. 🙂

    • @user-bi7nq4nj7q
      @user-bi7nq4nj7q 3 роки тому

      @@Dani_Krossing i think you misunderstand; the added line is the final fix to the issue I was having. I did other things to show the case-sensitive issue, the strtolower() was the catch-all final fix to make the issue compatible cross-platform. Looking through the other comments, shows the issue isnt isolated to me. I eventually changed my class name(s) back to beginning with cap letter. But again, it wont work unless the strtolower() is in place. Glad to contribute however. When you update the videos, consider the diversity of our differing environments?

    • @phiomiam
      @phiomiam 2 роки тому +2

      @@user-bi7nq4nj7q I'm a Linux user and run into the same problem. However I was trying to add your code to fix this issue bet... is it possible to get all file's code? Thanks

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

    That switch joke was terrible, but in the good way. I also laughed on your self reaction :D:D

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

    The switch joke had me dying XD

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

    I am new in terms of learning PHP. I learned Javascript before PHP, so I am sorry if this question makes no sense. Why do we need to post those data to another PHP page? Can it be done on the same page? The benefit to posting those data to another PHP is that our code looks cleaner? And if we posted those data on another PHP page, how can we use it on the index page? Do we have to use the session, return to the index page and access that particular value via session?

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

      We send the data to another script file for a couple of reasons. 🙂 By doing so we make sure that the PHP code isn't run, unless the user actively triggers the need for it.
      Keeping PHP code in our HTML files (for example the index page), is only meant for code that is needed on that specific page. Like for example if we need PHP to write error messages on that page. And even then, I would personally just create a class named ErrorMessages, and have methods in there which can print various types of error messages, in case I need to use them multiple times.
      By splitting code into separate files, we also ensure that our HTML files don't become overly long or complex, which will both cause extra load times and cluttering in our files. This is one of the benefits of using classes, or even functions.
      And to answer your question, any data that needs to generally be accessible on your entire website, you store in the session for easy access. Let's say the users "username" for example, we don't want to fetch from the database EVERY time we need it, since it causes extra unnecessary load times.

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

      @@Dani_Krossing Thank you! I understood now!

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

    well explained. I love it.

  • @DrSeuss100
    @DrSeuss100 3 місяці тому

    calc is calculator btw if youre new here.. he's just using slang

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

    Anyway you can do it with Ajax so the result won't go to a new page but instead be displayed on the same page? That was we can use the calculator over and over again without having to go back to the index page?

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

    Smooth $operator!!

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

    just to let you know I didn't understand a thing maybe you should explain more on auto load and why you do these changes!

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

      Everything explained in this video has been a separate lesson leading up to this video. As well as “autoload” 🙂 If you didn’t skip those videos, then I can’t explain it any better.

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

      @@Dani_Krossing i did watch your autoload video in this playlist, the thing is I am confused on why are you changing it and pls do explain the change code bit more.

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

    Should not the constructor method be in the try catch?
    If a type error occurs, there will be already an error in the constructor

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

    Thanks! Can you give us some PHP_HOMEWORK?

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

    i always use double quotes for string, isn't that bad practice?

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

    Why the whole if else check in the autoload function when you can use "require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/'. $className . $extension';"

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

    Excellent course.....but please make a fullstack complete project with php oops like social media blogpost like that till uploading to the server...thank you

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

    Whats the point of declaring the variable needs to be an integer, just to set it to be an integer yourself?
    Won't you get an error if you try to change text to an integer anyway? Either way you get an error, and have to make sure the input from user is an integer.
    So why take the extra step and declare strict mode?

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

      he did it on purpose so you could point it out and then share it with us
      he's a master teacher

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

    neat automaticly casted into float when do division

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

    Very nice tutorial up to now. I like your style and pacing a lot. It's just... you do use some peculiar or old-fashioned conventions, it's best to stick to PSR in my opinion. However, there's one thing that left me a bit flabberghasted and that's the include file which you put in the form action. That's as weird as prime beef in a sausage. I understand that you want to promote separation of concerns, but why not make a copy of index.php, ditch the form and put everything from calc.inc.php in there? Or just include calc.inc.php if you really want to use an include? Anyway, that't up till now my only peeve, the rest of the course gets an 11 out of 10.

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

    Hi Mr Daniel I've watched your videos and they're superb thanks so much for everything but I have a problem with one. The comments video...when I click submit, the comments don't go into the database. Please help😭🙏

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

    Yea the reason for the separate file is because of the "Form action"

  • @augischadiegils.5109
    @augischadiegils.5109 3 роки тому

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

    I'm watching your series to learn OOP in PHP (I've been using OOP in other languages for ages and I've been using PHP for ages, just never OOP PHP) and the videos are great for this purpose. But if I try to imagine a person who is also learning OOP from these videos, I think he could get really confused now. Because this must be the worst example of a practical use of a class I've ever seen :-) Why would you store the two numbers and the operator in class properties using the constructor, just to be able to call a method to do some calculation on them and then never use them again? I would probably ask - oh wait, couldn't you just make a function compute(int $a, int $b, string $operator)? Please don't take me wrong, I think you are a great teacher and your videos taught me a lot in a short time. But I think that even a negative feedback can be usefull ;-)

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

    To anyone who might know the answer. Is it possible to display the results in the index.php page? Other than using the header() function.

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

    I got an error (unsupported declare_types) and I am using php version 5.6.38....
    Kindly any one tell me what i will do?

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

    19:45

  • @hey-simba
    @hey-simba 3 роки тому

    there is no use of // include "includes/ClassAutoLoader.php"; in top of index.php please correct me if i am wrong

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

    Need more example! Thank you!

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

      Examples of php calculator or what ?

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

    you are cool.

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

    You talk about how we will be distracted because of the thing you have and yet you are actually the distracted one hahhhahaa.

  • @ryzzkurczaka6197
    @ryzzkurczaka6197 Рік тому +2

    Nice video elon musk

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

    What editor you use?

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

      This is Atom editor

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

      @@Urti thx

  • @Michael-tm9ke
    @Michael-tm9ke 4 роки тому

    You look kinda like Elon Musk. Good course BTW.

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

    Now I can see 😁

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

    Fantastic one. I believe I could also use if(strpos ($url, 'includes' ) == true){} insted of if(strpos($url, 'includes') !== false){}

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

      Not exactly, because it only returns false if it doesnt appear in a string, and if it is inna string then it returns index of the first letter of word you are looking for😊

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

    Why not use PSR-2 and PSR-4?

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

    retrying this activity again, because I can't find where to fix the error T-T autoload is taking its class name from the submit button. for ex. add.class.php. Hope I figure it out :< or maybe get some help in the comments

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

    This is what is called VMC Model ??

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

    what about division by zero

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

    I see why this is used... I just love progressive PHP instead of OOP... Why? IDK...

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

    wowwwwwwww

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

    Hi @mmtuts
    Why you use in class-autoload.inc.php
    if(strpos($url, 'includes') !== false){
    not
    if(strpos($url, 'includes') == true){ // Maybe it's better to understand it how it works .
    And when we talking about OOP maybe it's better way to create function for check $url ?
    Like this:
    function currentUrl() {
    $host = $_SERVER['HTTP_HOST'];
    $script = $_SERVER['REQUEST_URI'];
    return $host . $script ;
    }
    And when we want add something we just change the function.
    I would know what you think about it

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

      if(strpos($url, 'includes') == true) this statement is wrong, it works because php can convert any number to true. the strpos function returns either false or a number, so it is correct to ask if the result is not false.

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

      ​@@VitalijMik Thank you, you are right :)