We now have a youtube channel. Subscribe!

PHP for C Developers

PHP for C Developers


Hello folks! welcome back to a new edition of our tutorial on PHP. In this tutorial guide, we are going to be studying about PHP for C Developers.

The simplest way to describe PHP is as an interpreted C that you can embed into Html documents. PHP language itself is a lot like C, except with the untyped variables, whole lot of web-specific libraries built into it, and everything hooked directly to your server.

Statements and function definitions syntax should be familiar, except that variables are always preceded by $, and functions do not require separate prototype.


In this tutorial guide, we will list out some major similarities and differences between PHP and C.

Similarities between PHP and C

Similarities between PHP and C

  • Syntax - Generally speaking, PHP syntax is the same with that of C: the code is blank insensitive, statements are terminated with semicolons, function calls have identical form/structure (my_function (expression1, expression2)), and the curly braces ({and}) make statement into blocks. PHP have support for C and C++ style of commenting (/* */ and also //), and also Perl and shell script style (#).
  • Operators - The assignment operators (=, +=, *= etc.), the boolean operators (&&, ||, !), comparison operators (<,>, <=, >=, ==, !=), and the basic arithmetic operators (+, -, *, /, %) all function in PHP as they do in C.
  • Control structure - All of the basic control structures (if, switch, while, for) behave as they do in C, and including the support for break as well as continue statement. One significant difference is that switch in PHP can receive strings as case identifiers.
  • Function names - When you read the documentation, you will come across too many function names that look so identical with that of C.


Differences between PHP and C

Differences between PHP and C

  • Dollar sign - All the variables are denoted with a leading $ sign. Variables do not need to be declared in advance of assignments, and they have no intrinsic types.
  • Types - PHP language have only two numeric types: the integer (which corresponds to long in C), double (which corresponds to double in C). Strings are of random length in PHP. There is no separate character types.
  • Type conversation - Types are not checked at compile time, and type errors do not usually occur at the runtime either. Instead, variables and values are being converted automatically across types as needed.
  • Arrays - Arrays have syntax so similar to C's array syntax but they are both executed completely differently. They are in fact associative arrays or hashes, and the index can be either a number or string. They are not required to be declared or even allocated in advance.
  • Compilation & linking - No separate compilation steps for PHP scripts.
  • Permissiveness - Generally, PHP is more forgiving than C (mostly in its type system) and so let you get away with new kinds of mistakes. PHP program create unexpected result more than errors.
  • No prototypes - Functions do not need to be declared before their implementation is defined, inasmuch as you can find the definition some where in the contemporary code file or included file.
  • No pointers - There are no pointers in PHP. Though the tapeless variables plays the same role. PHP do support variable references. You can as well emulate the function pointers to some extent, in that function names can be stored in variables and also called by using the variables rather than a literal name.
  • Memory management - The Php is effectively a garbage-collected environment and in small scripts, there is no need to do deallocation. You should freely allocate brand new structures such as new strings and object instances.


Alright guys! This is where we are rounding up for this tutorial post. In our next tutorial guide, we are going to be discussing about PHP for Perl Developers.

Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.

Post a Comment

Hello dear readers! Please kindly try your best to make sure your comments comply with our comment policy guidelines. You can visit our comment policy page to view these guidelines which are clearly stated. Thank you.
© 2023 ‧ WebDesignTutorialz. All rights reserved. Developed by Jago Desain