PHP for Programmer C
The simplest way to think of PHP is like C is interpreted to be able to embed HTML documents. PHP is quite similar to C, except for untyped variables, Web-specific libraries are available, and everything is hooked up directly to your favorite Web Server.
The syntax of functions and function definitions is quite similar, except that there must always be $ before the variable name and the function does not require a separate prototype.
Here are some similarities and differences between PHP and C:
The similarity between PHP and C
Syntax - In general, PHP syntax is the same as in C: Code is irrespective of space (blank), the command is ended with a semicolon, the function call has the same structure (my_function (expression1, expression2)) , and curly braces ({and}) create blocks. PHP supports C and C ++ comments (/ * * / as well as //), Perl and Shell-script types (#).
Operator - Assignment operators (=, + =, * =, .), operators, logical operators (&&, ||,!), Comparison operators (<,>, <=,> =, ==,! =), and the basic arithmetic operators (+, -, *, /,%) operate in PHP the way they do in C.
Control structure - Basic control structures (if, switch, while, for) operate as they do in C, including support for breaks and continue. One notable difference is that the switch in PHP can accept strings as identifiers.
Function Name - When you study Documentation about PHP, you will see many function names that seem to be identical to C functions.
The difference between PHP and C
Symbol $ - Must have $ set the variable name. Variables do not need to be declared before the assignment, and they do not have an intrinsic type.
Type - PHP only has two numeric types: Integer (corresponding to a long in C) and double (corresponding to a double in C). String (string) of arbitrary length. There are no individual character types.
Type conversion - Type not checked at compile time, and type errors do not appear at runtime. Instead, variables and values are automatically converted when needed.
Array (Array) - Arrays with a syntax that are similar to the array C syntax, but how they are implemented are completely different. They are actually associative or hash arrays, and the index can be a number or a string. They do not need to be declared or allocated memory.
No structure type - There is no structure in PHP, partly because array and object types together make it unnecessary. Elements of an array in PHP are not a homogeneous type.
No pointers - There are no pointers available in PHP, although variables play a similar role. PHP does not support variable references. You can also simulate function pointers to several ranges, in which function names can be stored in variables and called using variables rather than a constant name.
There is no Prototype - Functions do not need to be declared before their implementer is defined, provided that the definition can be found somewhere in the currently included code or file.
Memory management - PHP effectively performs code cleanup, and with small scripts, there is no need to perform any memory release. You are free to allocate memory for new structures, for example, new strings and instances of objects. In PHP 5, it is possible for destructor definitions for objects. Destructor is called when the last reference to an object leaves the scope, before the memory is restored.
Compiler and link - There are no separate compilation steps for PHP scripts.
More arbitrary - PHP is more free than C (especially in its style system), and so you can avoid new types of errors. Unexpected results are more common than Error.
According to Tutorialspoint
Previous article: Object-oriented programming in PHP
Next lesson: PHP for PERL Programmers
You should read it
- What is raid? Common types of RAID compare their similarities and differences
- What is an HDMI cable? How many types of HDMI cables are there? The similarities and differences between them
- 10 differences between 'men' and 'boys'
- 8 most important differences between Mac and Windows PC
- Compare USB4 and Thunderbolt 4
- What is the difference between Ubuntu Desktop and Ubuntu Server?
- Differences between documents and forms (templates) in Word
- Tips to avoid burn out syndrome for programmers
May be interested
- 13 IDEs in the browser that every programmer should knowmany browser-based ides are suitable for programming in the cloud. most of these tools have limitations when compared to offline competitors, but they are slowly improving over time.
- How to Become a Full Stack Programmera full-stack programmer is a versatile developer who has experience and understanding of front-end and back-end software and hardware. full-stack developers also have a firm grasp of a multitude of programming languages, making them agile...
- A programmer writes an operating system to communicate with God through computersterry davis, a programmer who wanted to show his love to god, spent more than 10 years building the templeos operating system.
- 13 skills that every programmer needs to mastersome programmers are highly qualified to develop at work, but they are not really successful when missing other essentials. check out what skills to become a successful programmer in the article below.
- A programmer discovered a serious vulnerability of Steam but only received 460 million VNDa programmer with the nickname 'moskowsky' posted on the hackerone forum about how he discovered a serious security vulnerability that allowed him to download the entire game without losing any money.
- Meet the 82-year-old female programmer in Japanlet's tipsmake.com find out about 82-year-old female programmer in japan in this article!
- How to become an Android application developer?daily-used mobile applications have changed in the way we conduct business, communicate, entertain and learn new things. invite you with tipsmake.com refer to the article how to become an android application developer below!
- In the CPU tasks that Mario had to handle in the first two seconds of 1988, the programmer obtained 3000 sheets of papera programmer turned every frame in the first 2 seconds of super mario bros. super product. 3 into code and images and then print out paper. as a result, the guy has a total of 3,000 sheets, stacked up to 15cm high.
- JC-B1 - The device turns old iPhone battery into new onejc programmer jc-b1 made in china can bypass the ios operating system to display incorrect information on iphone, turn a low battery health indicator battery into 100%, deceive users.
- How to become a good software developer?becoming a software developer is a lucrative career plan. let's tipsmake.com think and start step by step to become a good software developer. we believe you can absolutely do it!