Perl VS PHP 比較表
這份之前找到的 Perl VS PHP 的對照表,不過原始網站連不進去,幸好當初有另存下來. 先貼起來放著. 以防流失...
原始網站: Perl/Php Translation
其它參考可見: PHP in contrast to Perl
td { font-family: helvetica,arial; } pre,xmp { font-family: courier; } a { text-decoration:none; color: blue; font-weight:bold; } a:hover { color: green; text-decoration:underline; }
Perl/PHP Translation
— 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+)/",$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; |
$dbh = MysqL_connect( 'localhost',$usr,$pwd ); MysqL_query('USE test') MysqL_query( $sql_op ); $results = MysqL_query( $sql_op ); while($record = MysqL_fetch_row($results)) { .. } "'" . addslashes($val) . "'" |
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。