Reply to Re: Error messages

Your name:

Reply:


Posted by ZeldorBlat on 08/28/07 14:08

On Aug 28, 9:46 am, "Fabio" <znt.fa...@virgilio.it> wrote:
> Hi,
>
> One question.
>
> I set to php.ini this
>
> error_reporting=E_ALL & ~E_NOTICE
>
> to be a list of error messages and some warnings/tips on the code written.
>
> All good, but if I have code like
>
> ------------------------
> function foo(string $x)
> {
> echo($x);
>
> }
>
> foo("hi");
> ------------------------
>
> I got this error
>
> ------------------------
> Catchable fatal error: Argument 1 passed to foo() must be an instance of
> string, string given, called in E:\Work\php\phpFramework\test.php on line 8
> and defined in E:\Work\php\phpFramework\test.php on line 3
> ------------------------
>
> !!!but... is not "hi" a string???
> What kind of *Catchable fatal error* would be this???
>
> :)
>
> I write foo(string $x) exactly to say that the function need a string!
>
> Thanks

The type hinting is for objects and arrays only. So, with the code
you've got, PHP expects the argument to be an object of class "string"
rather than the primitive string. Take that out of your function
declaration and it should be fine.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация