Integrating PHP and Perl
Perl is a language often associated with text processing and CGI. PHP is
a language often associated with dynamic Web pages. Both are very popular
with Web developers. Often, each of these languages is used at the expense of
the other. Hard-core Perl developers would love to develop everything in
Perl, and PHP developers tend to stick with PHP.
As usual in the Open Source
world, there is a lot of zealotry between users of each language. If you
think that one of these languages is perfect and the other is lame,
this article is not for you! This article is for those who take a more
pragmatic approach and use what works best for them. Each language has
its strengths and limitations. Personally, I use both languages at work
and at home. With time, I have discovered which language is best for which
tasks and
try to integrate the strengths of each language as much as possible to
complete my work quickly.
Perl is extremely good at
system administration and extensive data processing, among other
things. This means, if you want to do some extensive processing on a text
report, Perl would be preferable, as it provides handy
regular-expression-enabled text comparisons, which make it so much easier to
search through a report. Perl also has extensive string manipulation
features. Perl, by virtue of being older than PHP and having an extensive
community, has thousands of extensions archived in CPAN, which allow
one to do virtually anything with the language, conveniently. from XML
processing to writing to parallel port devices, CPAN includes
everything. CPAN is the reason Perl continues to be useful to a
large number of developers to date. Although it is not impossible to do
everything described here with PHP and a mixture of other languages, it's
simply more convenient with
Perl.
PHP is extremely good at integration with Web pages and databases. PHP
integrates nicely with static HTML Web pages. That's why it's so
popular and has
Ïà¹ØÎĵµ£º
<?php
$host = "www.abc.com"; //ÄãÒª·ÃÎʵÄÓòÃû
$target = "/test.asp"; //ÄãÒª·ÃÎʵÄÒ³ÃæµØÖ·
$referer = "http://www.abcdefg.com/abc.html"; //αÔìÀ´Â·Ò³Ãæ
$fp = fsockopen($host, 80, $errno, $errstr, 30);
if (!$fp){
echo "$errstr($errno)<br />\n";
} ......
µ¥ÒýºÅ'ºÍË«ÒýºÅ"µÄÇø±ð£º
Ê×ÏÈÊǵ¥ÒýºÅÒª±ÈË«ÒýºÅÖ´ÐÐЧÂÊÒª¸ß£¬ÒòΪ˫ÒýºÅ»á¶ÔÄÚÈݽøÐÐÔ¤´¦Àí¡£
ÀýÈ磺'$value' Êä³ö×Ö·û $value ; "$value"Êä³ö±äÁ¿$valueµÄÖµ¡£
charºÍvarcharµÄÇø±ð£º
charÊǶ¨³¤¶øvarcharÊDZ䳤£¬charµÄÖ÷ÒªÌصãÊÇ´æ´¢·½Ê½Ô¤·ÖÅ䣬varcharµ±ËüµÄÊý¾Ý³¤¶È·¢Éú±ä»¯Ê±»áÓ ......
×î½üÒ»Ö±ÔÚ×ö×Ô¼ºµÄͼÊéÕ¾£¬·Ö±ðʹÓùý½ÜÆæºÍ¶Á°ÉÁ½Ìײ»Í¬µÄϵͳ£¬¶ÔÓÚÕâÁ½Ì×ϵͳҲÊÇÓÖ°®ÓÖºÞ£¬°®µÄÊÇËûÃǵŦÄÜÇ¿´ó£¬ºÞËûÃǶ¼Í¬ÊôûÓпªÔ´¾«ÉñµÄ²úÎï¡£ºÇºÇ£¬×÷ΪһÃûÇî³ÌÐòÔ±£¬°³¿ÉÒÔÀí½â×÷ÕߵĿàÖÔ£¬ÕâÀï¾Í²»ÅúÅÐÁË¡£
Äê¼ÙÆڼ䣬ÎÞÊ¿É×ö£¬·¿´×Ô¼ºÒÔÇ°µÄ²É¼¯´úÂ룬·¢Ïֺܶà¿ÉÒÔÓÅ»¯ºÍÌáÉýµÄµØ·½£¬¾Í¼òµ¥×öÁËÏÂÓÅ» ......
ÔÚ±à³ÌµÄ¹ý³Ìµ±ÖÐ,×Ö·û´®µÄ²Ù×÷ÊǷdz£ÖØÒªµÄ²¢ÇÒ¾³£»á±»Óõ½,×Ö·û´®³£ÓõIJÙ×÷¾ßÌåµÄ°üÀ¨×Ö·û´®µÄÆ´½Ó,Ìæ»»×Ö·û´®,²éÕÒ×Ö·û´®,±È½Ï×Ö·û´®,¸´ÖÆ×Ö·û´®ÒÔ¼°¼ÆËã×Ö·û´®µÄ³¤¶ÈµÈµÈ.
1,Æ´½Ó×Ö·û´®
Æ´½Ó×Ö·û´®ÊÇ×î³£Óõ½µÄ×Ö·û´®²Ù×÷Ö®Ò»,ÔÚPHPÖÐÖ§³ÖÈýÖÖ·½Ê½¶Ô×Ö·û´®½øÐÐÆ´½Ó²Ù×÷,·Ö±ðÊÇÔ²µã.·Ö¸ô·û{}²Ù×÷,»¹ÓÐÔ²µãµÈºÅ.=À´½ø ......
pack/unpackµÄÃþ°å×Ö·û×Ö·ûº¬Òå
format ²ÎÊýµÄ¿ÉÄÜÖµ£º
a - NUL-padded string
A - SPACE-padded string
h - Hex string, low nibble first
H - Hex string, high nibble first
c - signed char
C - unsigned char
s - signed short (always 16 bit, machine byte order)
S - unsigned short (always 16 bi ......