10: Type Declarations In OOP PHP | Type Hinting In PHP | Object Oriented PHP Tutorial | PHP Tutorial

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

КОМЕНТАРІ • 70

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

    Hi everyone!
    It has been a while since the last upload. I have had my office under maintenance, and I have had technical issues with my PC and the equipment I use to record videos, which is the reason why it took so long. I'm still having technical issues but I'm hoping that I'll manage recording until I get it fixed.

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

      bro nice teaching skills you doing great job man.

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

      i know it's kinda randomly asking but do anyone know of a good place to stream newly released movies online?

  • @pedrofernandez9707
    @pedrofernandez9707 4 роки тому +15

    I have to say it Daniel, it has been few years since the last time I was into progamming, and I just wanted to refresh my knowledge. Your content is so specific and entertaining that I've watched 10 episodes today while practicing. Great work, and thank you for sharing you're knowledge with us.

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

    Finally Learn Half OOP PHP in Just Few Hours! Thanks Daniel for Such Awesome Tutorials!! Better Than What Teacher Teaches!!

  • @edgar-mmxxiii
    @edgar-mmxxiii 3 роки тому +3

    Strict typing is always a good thing to do in coding. It helps avoid unpredictable results and debugging headaches.

  • @YPLabs
    @YPLabs 5 років тому +16

    Thank you so much!
    I have watched all the OOP PHP tuts of yours, but you never mentioned or promote some of your products (if you have any).
    If you dont have products, create some udemy courses or something (some way people can support you).
    Use the platform to your advantage still give free info like this but also promote your business.
    You are a very nice guy, keep it up!

    • @suong534
      @suong534 5 років тому +13

      He had mention before that he doesn't want to put his content on Udemy because he wants everyone access his content for free. You can support him by donate on patreon 😉

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

    Great course, thank you, I've been programming for years but always worked procedurally (!) which has really held me back in the modern world. As a 'C' programmer though not declaring types has always made me a bit uneasy when working with PHP - at last, the mystery resolved! Thanks mate :)

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

    Thank you so much Dani.. I really enjoy your teaching... I was at the verge of giving up on coding when I came across some of your tutorials, and ever since then I have been coding again and now I have fallen in love with it.
    Thank you so much man.

  • @MSKWebServices
    @MSKWebServices 4 місяці тому

    Following your tutorial since 2018

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

    You're an incredibly awesome tutor! Thank you very much! You just taught me PHP.

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

    That's great, php 7 changed the game , this was great lesson and opened my mind for other opportunities for my codes.

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

    It's great to have you back.
    Pls, if you won't mind making a video on like and unlike button to an article page also a hit counter which count the number of visits or views to the article page. Thanks so much in advance.

  • @aldrinjohnencina6153
    @aldrinjohnencina6153 10 місяців тому

    thank you so much. you explained it clearly.

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

    This guy is the best i tell you...

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

    Want a project with OOP PHP.Keep up the good work

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

    you are incredibly awesome tutor
    thanks so much
    I really needed it

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

    your videos are great! please ever make a video on visitors count in website using cookies. Thanks for your awesome videos and for your teaching . keep up the good work.....

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

    thank you sir

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

    The best like always, top man! Thanks

  • @jandefajardo7136
    @jandefajardo7136 5 років тому +7

    Hi, do you have a CRUD tutorial for OOP PHP?

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

    Hahaha cracking with the patches on the video , so funny

  • @christye-x8k
    @christye-x8k 3 місяці тому

    You are good sir, upload your tutorials on UDEMY to make more cashflow.

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

    this part of video was nice

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

    thank you

  • @NawabKhan-vq5de
    @NawabKhan-vq5de 5 років тому

    amazing sir keep it .
    We are waiting for your more tut

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

    Nice video! Maybe you could also say something about defining return types for methods.

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

    Thank you so much!

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

    Hi, you probably know what is magic method. Do you use it in your projects or you recommend more to you use regular syntax for getters and setter as in you example?
    P.s just a thought: you can add int, string, array and other Type Declarations into parameters, for example:
    public int $name ;
    it would be faster and easier to find. unless you will need every time to call setters to change data type. But I am not sure how often it would be needed.

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

    Thank u very much for this cool course. I have a question, Is enabling restrict mode may cause some security problems?

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

    Hi Dani,
    I should really appretiate your effort and Still on 2022 someone is out there learning oop php from your video.
    Thank you so much for that. however, around time 3:30 yo say by double quote we can assign integer as string which actually happened in my code that i copied yours, where if i pass setname(2) without the double quote there is an error message but when i setName("2") then there is no error, but around 3:40 you said this has to be an error message. but no error was shown even though i have declared the strict type 1 in my index file.
    Your help and answer would be much appretiated
    thank you.

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

    That is a great thing, but i think that it doesn't matter what type is user giving because anything that is typed in forms is going to be string, and that is the only way that we let user communicate with our app, but anyway i didn't know about this and it's great that php is going in that direction

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

      Type Declarations isn't as much meant to catch errors the user generates through primitive data types, it is more meant for the developer. In our case here in this course, for when we start working with instances of other classes or the same class. However either way, it is seen as best practice to use Type Declaration whether or not you are working with primitive data types or not.

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

    Hi mm,
    but this works just if you declare type inside the parentheses?

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

    ty

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

    What PHP version are you using? the type declaration is not allowed anymore in php7, can only be used to force the types of objects and arrays

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

      If you go to the official PHP.net documentation, it doesn’t say type declaration isn’t allowed anymore. Can you provide evidence of this claim?

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

      @@Dani_Krossing I am very sorry, my bad, it's all the way around.
      I am running PHP 5.6 and prior to PHP 7 type hinting can only be used to force the types of objects and arrays. In my case the error that I get is "Argument 1 passed to Person::__construct() must be an instance of string, string given, called in".
      sorry

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

      Just glad it got cleared up :)

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

    Hallo, can you make a video about how to scale Ifram to work width the content? I am using that for some of my client`s website for embedding booking website for courses?

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

    Hello, I want to know, is it possible to give type hinting to roles and permissions separately?
    public function getRoles(): array
    {
    if (Gate::allows('role_access')) {
    $roles = Role::with('permissions')->orderBy('id', 'DESC')->get();
    $permissions = Permission::all();
    return [
    'roles' => $roles,
    'permissions' => $permissions
    ];
    }
    }

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

    Awesome

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

    declare(strict_type = 1) must be first line of code, aswell as session_start()
    What if I have to use both and the same time ?
    Btw why wouldn't I go for **if(is_string($var)) {//code here}**

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

      strict_type can go above the session_start, but they do not interfeer so it doesn't actually matter.
      you can check on string manually, and probably should. Declaring types helps future developer understanding what type should be passed to the method/function, and a good IDE can warn you even before you run your code that there is some type missmatch

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

    But what if you were to pass in the digit "2" as parameter with strict mode set to 1? Wouldn't it take that 2 as string too and spit out 2 on the browser as output too?? When you explained it before altering the code to practicality you mentioned one can't even pass the digit as string if it's wrapped in double quotes with strict mode enabled or strict mode set to 1(true)!

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

    I have some problem bro.i have mssql database date .i wrote the program to received the data in to the html table.now i want to get the table data and store in the mysql data table .how do i solved the question??

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

    Using Strict Types What Type Would this __Construct Function be:
    function __construct( $db=NULL, $cookie_prefix = 'usr' . ':' . 'hash-cookie' .bin2hex(16), $table_wildcard = '%t' )
    Would it be a String, Has numbers in it aswell...

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

    Hi Daniel,
    I have made a registration form using your tutorials and was wondering if there is a way to get and show errors on the form without using the URL and GET method.

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

      I found a way to do this using $_SESSION

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

    Will u do unity tutorials?

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

    I start to use type declarations in my functions but just for int, string and array without strict_type = 1, I use these just to help the future developer to know how type of dato should go there... is a correct way to do that?

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

      That is ok, it is also very useful for your IDE, as it will know as well what type is expected, so it can show you error message (type missmatch) even before you run your code.

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

    I like your teaching style. However, one issue I've found is that the course as it's set up now is not using consistent files, which is making this difficult to follow. This particular lesson is throwing an error because too few arguments are being passed. I believe this is because the __construct method was deleted at some point, but this isn't shown. You also didn't include the name space from the previous lesson.
    Some of this is pretty easy to figure out, but having to figure out errors unrelated to the lessons distracts from learning the concept of the course. Especially when you introduce a concept - such as name space and constructor - and then don't use it in subsequent videos.

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

  • @albashir-academy
    @albashir-academy 5 років тому

    What editor do you use?

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

      Looks like Atom (atom.io/)

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

      Kakarott Milan Atom

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

    Great tutorial. However I was not able to get any errors on my browser and I had to use
    ini_set('display_errors', '1');
    error_reporting(E_ALL);

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

    while I trying this tutorial. I get an error message that " Fatal error: Class 'Dbh' not found "

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

      Have you followed previous tutorial ?
      Make sure you gave the right path of the class.

  • @SalmanKhan-wt8rx
    @SalmanKhan-wt8rx 5 років тому

    I am new to coding. And honestly saying I have watched many videos to understand OOP but couldn't figure it out. I am badly waiting for your videos but it seems like you have a technical issue. I am expecting some practice videos on OOP afterwards.

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

    Dear Mr denial Hi iam an amateur in web development i have an issue hope that you can help me with
    --- i cant understand tutorial that about .htaccess the way you redirect all requests to index.php then use $_SERVER['REQUEST_URI'] can you please do that tutorial for us really appreciate your effort and thanks in advance

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

    why you have delete rest of the videos???

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

      Hi, I haven't deleted the videos. I just removed them from the playlist since the order of the videos didn't make sense anymore. Newer videos are planned for the future, however if you want to see the old ones I removed, you can find them on my channel.

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

    another one

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

    declare("strict_types = 1);

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

    Isn't strict_type = 1 kinda ironic? 😂

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

    Thank you