Beginner PHP Tutorial – 186 – try, throw, catch

[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –


Posted

in

by

Tags:

Comments

16 responses to “Beginner PHP Tutorial – 186 – try, throw, catch”

  1. reynan delizo Avatar

    Hi! if you use PDO in try you need to write PDO with exception in catch?

  2. Roy Miller Avatar

    I can't really wrap my head around the purpose of those function why not just echo'ing out a block of text???

  3. ITSplit Avatar

    Isn't this the same as:

    $age = 16;

    if($age > 18) {
    echo "Old enough";
    } else {
    echo "Not old enough";
    }

    In other words, I don't understand for what is this good!

  4. Nitros64 Avatar

    In java is better

  5. V. Peters Avatar

    <?php

    $age = 16;

    try {
        
        if ($age>18) {
            echo 'Old enough.';
        }
        else {
            throw new Exception ('Not old enough');
             }
           
    } catch (Exception $ex) {
        echo 'Error: '.$ex->getMessage();
        
    }

    ?>

  6. john mart belamide Avatar

    I also used this is my C# database program in displaying ,converting and saving image into the database

  7. Peristilo peris Avatar

    Guys, help me, please! Why is this useful? I can use IF ELSE and echo a message without using all these weird synttax. How can "try, throw, catch" be really useful in real world? I just dont get it!

  8. Rahil Wazir Avatar

    i just learned this on java and seen here looks easy

  9. Arthur Hernandez Avatar

    is it me or do all these symbols have a meaning but the "->" makes sense because what it really is saying "make this even to whatever it is pointing to" by subtracting something that is greater than something to make it equal . so it really is saying that the variable is equal to a function so we have a $variable pointing -> to a function . or it can be the correct syntax to point to something … but it does make sense going by arithmetics if you think about it

  10. PancakePlease Avatar

    @bradudebra next tutorial covers this. make class and extend exceptions.

  11. Paweł Dziubałka Avatar

    @bradudebra
    Don't you just type in other message in Exception?

  12. Will Baizer Avatar

    But real question, what if there is more than one exception?

Leave a Reply

Your email address will not be published. Required fields are marked *