Monday, June 9, 2008

Love Sharing Knowledge

So out of the blue my C++ experience had it's shining moment today. I was able to share some of my infinite knowledge of C++ with my manager and fellow team-mate (yes singular).

Type casting, a very old (pre-dating C++ all the way to C), syntax was in fact inherited by PHP. You can force a type on any value, even though in PHP types are very loose, so that if a function from some random library requires a certain type, it will not warn you or error out. This is very useful when ensuring that your releases do not contain errors, warnings or notices.

This technique only works for basic types: bool, string, integer, and foat, The following is the syntax:

()$myVariable

ie.: (string)$var

Hope this helps in the future of everyone's programming endeavors.


Loushou.

No comments: