Best Tutorials website


From C/C++ to PHP

From C/C++ to PHP

In this tutorial we will discuss pitfalls that a typical C/C++ developer is likely to encounter when starting coding in PHP. If you are unfamiliar with PHP at all we suggest that you follow links to PHP manual provided in this tutorial and then come back to find out what you should take care of.

We will start with comparison operators. In PHP, a function can generate mixed result type. For example, function strstr that finds first occurrence of a substring in a string might return NULL if the substring is not found or 0 if the string starts with the substring. In C/C++, it is impossible to distinguish between 0 and NULL. Type casting is different in PHP when applied to objects.

There is pass-by-reference mode in C/C++. In PHP, references are used instead of pointers but they are not as powerful and there are cases when you cannot use them. We will discuss those special cases.

Object inheritance is available in PHP 4.x. However, function overloading implementation is different from that in C/C++.

Finally, we will discuss regular expressions.




Views: 931 | Rating star | by Daniel




View this tutorial
Broken link Report broken link?