Re: Extending Exception

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 21 July 2010 16:14, Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Wed, 2010-07-21 at 11:10 -0400, Christoph Boget wrote:
>
>> Ok, so taking the sample code that is on the page
>>
>> http://us3.php.net/manual/en/language.exceptions.extending.php
>>
>> Literally, just cutting and pasting the code.  When I try to
>>
>> throw new Exception( 'My Message' );
>>
>> PHP spits out the following fatal error:
>>
>> Fatal error: Wrong parameters for Exception([string $exception [, long $code ]])
>>
>> and the line number it dies on is the line in the
>> MyException::__construct() where it is calling the parent's
>> constructor.  So what's going on?  Is the documentation wrong?  Is
>> this a bug?  Am I doing something wrong?
>>
>> I'm using PHP 5.2.9.
>>
>> thnx,
>> Christoph
>>
>
>
> Well, it's not really a copy and paste job, as you've omitted the second
> argument to the Exception method, which is what the error is complaining
> about.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

Ashley, the second argument is optional, hence the [] around the [, long $code].

The issue is one of BC as I've described above. Removing the BC allows
the code to work as documented.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux