Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- var_dump(1 + 1); // int 2
- var_dump('1' + '1'); //int 2
- class One {
- public function __toString() {
- return '1';
- }
- }
- var_dump(new One + new One); // Object of class One could not be converted to int int 2
- var_dump((string)new One + (string)new One); // int 2
- var_dump(2 + 2); // int 4
- var_dump('2' + '2'); // int 4
- class Two {
- public function __toString() {
- return '2';
- }
- }
- var_dump(new Two + new Two); // Notice: Object of class Two could not be converted to int int 2
- var_dump((string)new Two + (string)new Two); // int 4
Add Comment
Please, Sign In to add comment