PHP for PERL Programmers
This chapter will list some of the major similarities and differences between PHP and PERL. This helps PERL programmers understand PHP faster and avoid common errors.
Similarities between PHP and PERL
Compiled Scripting Language - Both Perl and PHP are Scripting languages.
Syntax - PHP's basic syntax is quite similar to Perl, and both share a lot of syntactic characteristics with C. Code is indistinguishable from whitespace, semicolons ending with semicolons, and curly braces Create multiple commands into a single block. Call the function starting with the function name, followed by the actual parameters enclosed in parentheses and separated by commas.
$ Symbol before the variable - All variables in PHP are quite similar to scalar variables in Perl: $ symbol before the variable name.
Don't declare variables - As in Perl, you don't need to declare the type of a PHP variable before using it.
Variable types are quite free - As in Perl, variables in PHP have no intrinsic type, nothing other than the value they keep present. You can store either the number or string in the same variable.
Interpolation and string - Both PHP and Perl perform more compilation of double-quoted strings ("strings") than single-quoted strings ('string').
Differences between PHP and PERL
PHP can be embedded in HTML - Although it is possible to use PHP for arbitrary tasks by running it command line itself, it is more specific than being connected to the Web Server and used to create web pages. If you used to write CGI scripts in Perl, the main difference in PHP is that you don't need to explicitly print the big code blocks of static HTML by using the print or heredoc commands and instead, you have Can write HTML outside the PHP code block.
No variable type @ or% - PHP has only one variable type, starting with a $. Any data type in this language can be stored in these variables.
Array vs Hash - PHP has a single data type called Array, which plays both Hash and Array roles in Perl.
Determining parameters for functions - Calling functions in PHP looks pretty much like calling subroutines in Perl. Function definitions in PHP need some formal parameters like in C or Java, unlike in Perl.
Variable scope in function - In Perl, the default scope for variables is global. That is, the top-level variables are visible inside the subroutine. This increases the messy use of global variables in functions. In PHP, the variable scope in the function definition, by default, is local.
No Module System - In PHP, there is no real distinction between regular file code and file code used as an Imported Library.
Break and continue orders instead of next and last - PHP are quite similar to C and use break and continue commands instead of next and last orders.
No elsif - The difference in spelling is: elsif in Perl is elseif in PHP.
More comment types - In addition to single-line comments like Perl-style (#), PHp provides multi-line comments C-style (/ * comment * /) and single-line comments Java-style (// comment).
Regular Expression - PHP does not have a specific syntax available for Regular Expressions, but has most of the same features as in the Perl Integrated Regular Expression Functions.
Follow tutorialspoint
Previous post: PHP for Programmer C
Next lesson: Date & Time in PHP
You should read it
May be interested
- How to Allocate Dynamic Memory (C++)for most beginning programmers, the memory needs for the programs they have written have been predetermined before their program runs, such as when declaring the size of an array. but sometimes, we as programmers do not know exactly how...
- Join 'Best Developer In Vietnam 2019', the competition to find the best programmersall programmers in vietnam, from students to experts can register to participate.
- 5 interesting HTML and CSS features to look forward to in 2018join tipsmake.com to learn about 5 interesting html and css features to look forward to in 2018!
- Form a way of thinking like a programmerprogrammers are people who design, build and maintain computer software programs. in order to work as a programmer, you first need to form a way of thinking like a programmer.
- 13 basic programming channels in Vietnamese that every young person can learnif language is a barrier for you, study 13 basic programming channels completely in vietnamese today.
- How did the code that made the killer become a $ 100,000 programmer in Silicon Valley?after 22 years in prison, now zachary moore (38) sat surveying and checking the code in an open-space office in san francisco with a 6-digit salary.
- 7 best laptop models for programmersfinding and buying a laptop that suits your needs is essential for everyone, and even more important for programmers.
- 6 best laptop models for programmersfinding yourself a laptop that suits your needs is essential for everyone, and even more important for developers.
- GitHub launches 'Copilot', an AI that can code with yougithub has just officially launched a new ai programming tool called copilot. this tool will accompany programmers and developers to help them create more quality code in a variety of programming languages such as python, javascript, typescript, ruby and go.
- The 10 most wonderful 'shadows' of all time in the programming villagethe truth is that in the past, there are quite a few female programmers in the world, even they hold important positions. please name the 10 greatest pink balls of all time in the programming community that can make any brother in the industry to admire admiration.