Hi There..
Im totally new to php..so please excuse me if my question looks like an idiot
Is there a possibility to use exception withoust using try catch block
Let say i have Thing Class
And this how i use itPHP Code:
<?php
class Thing
{
public function __construct($required)
{
$this->foo();
if (!$required)
{
throw new Exception('$required is missing');
}
$this->bar();
}
public function foo()
{
echo "bla";
}
public function bar()
{
echo "blar";
}
}
See i need to use that class in try catch block..PHP Code:try
{
$myvar = new Thing($required);
}
catch (Exception $e)
{
$e->getMessage();
}
Its look really weird..Many php source code i have look into dosent have any try catch block in it
If i use that class without try catch block,i will got Fatal error
Is there a way that i can use that Thing class without wrap it in try catch block
Just like this
PHP Code:$myvar = new Thing($required);







Bookmarks