Re: Odd Code Error.
| From: | Martin Hjort Eriksen | Date: | Thu, 22 Jan 2004 00:03:11 +0000 |
| Subject: | Re: Odd Code Error. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-175364@lists.php.net to get a copy of this message | ||
daniel@electroteque.org wrote:
It is also because you cannot do it... :) It was an idea on how it could be done, with a little inspiration from pascal.Exactly how a variable should be set, well it could be for instance var $age:int;Where on the php site does it tell you to set it like that ? I've never seent that before ?
Well the changes document for PHP5 explains it pretty good: In PHP5 this: |<?php function foo(ClassName $object) { // ... } ?> | is equivalent to in PHP4: | <?php function foo($object) { if (!($object instanceof ClassName)) {But you could also do both things at the same time, for instance that you PHP5 can make class type hints about the parameters to a method, but you can also not do it.I dont get it do you have an example ?
die("Argument 1 must be an instance of ClassName");
}
}
?> |
Meaning that if you hint the class type of a parameter of your method, and you set the parameter with a different type when you call the parameter, it will produce an error.
You can read more about it here:
http://www.php.net/zend-engine-2.php
/Martin