Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: Is PHP datatyping broken?
2 points by superice on Jan 8, 2015 | hide | past | favorite | 1 comment
This gives an error: <?php $class = new StdClass(); $output = (null) $class; var_dump($class);

This outputs an empty object: <?php $object = (Object) null; var_dump($object);

Why is this?!



(null) type casting is not authorized in php. See http://php.net/manual/fr/language.types.type-juggling.php for information about type juggling.

And what do you think should happen in the second case? It looks normal to me.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: