Perl/Php Translation
arrays hashes data structures array split/join case conversion string comparisons functions | string matching operations basename/dirname environment variables POST/GET parameters HTML elements URL encode MySQL database access |
— Perl arrays — | — Php arrays — |
---|---|
@a = (); | $a = array(); |
— Perl hashes — | — Php hashes — |
---|---|
%h = (); | $h = array(); |
— Perl data structures — | — Php data structures — |
---|---|
%h = ('a'=>13, 'b'=>25); | $h = array('a'=>13, 'b'=>25); |
— Perl array split/join — | — Php array split/join — |
---|---|
@a = split( '|', $s ); | $a = preg_split( '/|/', $s, |
— Perl case conversion — | — Php case conversion — |
---|---|
$s = lc($s); | $s = strtolower($s); |
— Perl string comparisons — | — Php string comparisons — |
---|---|
$s1 eq $s2 | strcmp($s1,$s2) == 0 |
— Perl functions — | — Php functions — |
---|---|
sub foo { | function foo() { |
— Perl string matching operations — | — Php string matching operations — |
---|---|
$s =~ m/(w+)/; | preg_match( "/(w+)/", $s, $match ); |
— Perl basename/dirname — | — Php basename/dirname — |
---|---|
use File::Basename; |
|
— Perl environment variables — | — Php environment variables — |
---|---|
%ENV | $_SERVER |
— Perl POST/GET parameters — | — Php POST/GET parameters — |
---|---|
#form/hyperlink parameters: | #form/hyperlink parameters: |
— Perl HTML elements — | — Php HTML elements — |
---|---|
use CGI (:standard); | # The Perl/CGI functions have the |
— Perl URL encode — | — Php URL encode — |
---|---|
use URI::Escape; |
|
— Perl MySQL database access — | — Php MySQL database access — |
---|---|
use DBI; |
|