if ($num == (int) $num) {
//It’s whole
}
else {
//It’s not
}
So simple… more here
Art, Science & Philosophy
In PHP4, constructor has same name as class:
class Welcome {
function Welcome() {}}
In PHP5, constructor is always __construct():
class Welcome {
function __construct() {
}}
In PHP4, when you extend you call parent constructor like:
class Welcome extends Parent{
function Welcome() {
parent::Parent();
}}
In PHP 5, you extend like:
class Welcome extends Parent{
function __construct() {
parent::__construct();
}
I am using PHP5 but I was using PHP4 to extend my classes. Lovely!
Since I started working on my project, I have been realizing that I am coding like I did back in college. I am writing everything from scratch. Keeping everything neat and clean as if I will be submitting my project to a professor for a grade. So far I have been working on common tasks like user registration, session control, searching Amazon. I really want to get to exciting parts of programming core logic of my application. But I want to do everything my way. I like simplicity. I don’t want to learn someone else’s library. I guess I don’t mind re-inventing wheel.
At SXSWi, I discovered Facebook Connect. I fell in in love with it. My target demographics are same as Facebook’s. Facebook Connect can take care of user registration and session management.
Then I started working on Amazon web services part. Getting data from Amazon is easy but exciting. But ten other tasks like input validation, caching, parsing response and other tasks are boring.
Yesterday, somewhere on web I read about CakePHP. Since then I have been looking into different PHP Frameworks. Most of the time I was looking for reasons not to use any Framework. How can I trust someone else’s code. But then I saw this presentation and this convinced me to use frameworks.
Here are 2 main points that convinced me:
So which framework to use?
My choice right now is Code Igniter. It is one of the simplest PHP framework. I read documentation, and everything just made sense. Installation seems easy. (I haven’t tested it yet.) There seems to be good community around it. Then it is also one of the lightest and fastest PHP framework. Supposedly, you can use many libraries from other framework with Code Igniter too.
Other frameworks, I want to test out soon are CakePHP and Zend Framework.
Just found out that PHP has totally different variable scope than Java. In PHP you have specify global keyword inside the function not outside. I am so used to Java type variable scope.
For more info read here