PHP Programming
Group for all things PHP, Coding Help, Problems and Solutions
104 Members
Join this group to post and comment.
Information Technology
28 Jan 2019

How is php similar to C programming?

The simplest way you can think of php is an integrated C that you can attach to HTML documents. PHP language is very much similar to C, except the syntax for variables, the whole lot of web-specific libraries built-in, and everything hooked up directly to your favourite web server. 

The syntax are almost same except that the variables are preceded by the $ sign. The code in PHP is blank insensitive, statements are terminated by semicolon, function calls have the same structure, and  even loops are same. PHP supports C and C++ style comments (/**/ or //) and even perl and shell script(#).

All operators in C works same in PHP. The basic control system (if, if-else, while, for) works same as in C language including supporting break and continue. One notable difference is that switch in PHP can accept string case as well.

PHP only has two numeric types integer and doubles. Types are not checked at runtime and type errors do not typically occur at the time of run time. In PHP array are similar to C but they are executed differently. There are no pointers in PHP. There is no structure in PHP because the array and objects makes it difficult to execute. The PHP engine is a garbage collection environment and in small scale there is no need of any dealocation.