<?php
function logit (string $message)
{
echo "i´m here ";
}
mysql_query("foobar"); // ignore error message
logit(mysql_error());
?>
Ignoring the forced failure of mysql_query the following call to logit
brings this error message:
Catchable fatal error: Argument 1 passed to logit() must be an
instance of string, string given, called in ....... test.php
mysql_error should return string, logit requires string, where is the
real problem hidden?
best regards
a
areisinger wrote:
> mysql_error should return string, logit requires string, where is the
> real problem hidden?
There is no string class in PHP, so mysql_error() returns a string ( a
chain of characters ), and the logit function requires an object which
is an instance of a "string" class. And it's absolutely not exists
there.
Regards,
Sandor Nemeth
<?php
function logit ($message)
http://ch2.php.net/language.oop5.typehinting
"Type Hints can only be of the object and array (since PHP 5.1) type.
Traditional type hinting with int and string isn't supported."
Regards
i
"Type Hints can only be of the object and array (since PHP 5.1) type.
Traditional type hinting with int and string isn't supported."
http://php.net/manual/en/language.oop5.typehinting.php
Thanks for the answer