PHP/CURL Book with Examples
: ! &
: ! & S
: ! & S: ! & S
: ! & S
! & - ! & - & - " & -
& ! 0 - & -
& & ! % & # - )
/ ! & *! ! , & ! - # & !
& 0 & & ! & - - & - 0
# # ) - - & & B & - &
& ! ! ? % & BN
! & & % - ) & ! !
& ") & - % - & & " & & -
& & " & - & !
: 2 ) # !
: 2 ) # ! : 2 ) # !
: 2 ) # !
& S
& S & S
& S
"! & & # - & ) - & & ! "& ) +
. & ! & ! &
2% - & ! & !
3 & ! & !
4 & ! -
5 / & - ) & -
! & ) & & " & )
& ! ! *) & & ) - R T,
) & - ! " & - J% & ) - &
% ) #
: 3! & &
: 3! & & : 3! & &
: 3! & &
& ! ! *! & , ) ) & " & - %
& & - ! & - & ! & - & ! J !
& -
PHP/CURL Book with Examples
! & ( & & &
( ) " "4) & ! & +
! + ! & &
! + ! & &! + ! & &
! + ! & &
# !
!!
! * & ! & " & ! & ! K" ) ! M,
. & ! ! & ! % & & & & @
& % )
= & - & A - # & ! & & - & &
- - ! & ! " # - & &
) ! X ! KM & & # & !
& QX ! K2M & & # & ! & ! & - " & - &
X ! KM & & ) & ! -
2
22
2
! +
! + ! +
! + @
@@
@& & % ! & &
& & % ! & && & % ! & &
& & % ! & &
# !
! !
! * & ! & " & ! & ! K" ) ! M,
& & - & ! *, ! & - & & &
& ! #
3
33
3
! R +
! R + ! R +
! R + @
@@
@ # ! & &
# ! & & # ! & &
# ! & &
& ! R
! R ! R
! R * & ! & " & ! # EK" ) K"& ! MM,
. # E ! & ! % & & &
= % - - "& - X KM
& & - & "X KM %
- - & A - # & " & - &
! & # & ! ! +
' R 1 ( ( . R /
= ! " % ) & ! & - & & ! #
& - < & ! & % & & ) % ) &
& ) & & ! - & ! & - J & ! &
# E ! % # & 43
! R *, & & # & #
*& ,# ! R *, & !
! R R *,
! R R *, ! R R *,
! R R *,& & ) & & & & -
# E ! R *, & ( / . & -
4
44
4
! R +
! R + ! R +
! R + @
@@
@ # ! &
# ! & # ! &
# ! & /
/ /
/
&
& &
&
- ! R
! R ! R
! R * - & " - & " - # EK"& M,
PHP/CURL Book with Examples
. # E & & - & =
- "& & ) # - Q - @"
& -
& ) & & & NN& * & 44,X & "
# & ! - & % ) & # - # )
- # ) & J & A - & & & # ; ; " & - NN
X - # ) & 1 & & ! &
& - ! * & ! ,# & & # & !
# &
& & ! & & # & - )
- # ) & & # *+ & ! & # - )
- & ,") & & NN& & ) # &
NN" " - & ! R *, & - & &
) & NN# & - # ) "NN# &
- # ) & & ! =& & NX [\ &
- X # & " % & !
5
5 5
5
! R +
! R + ! R +
! R + ! & / &
! & / & ! & / &
! & / &
& ! ! R
! R ! R
! R * & ! & " & ! & " & ! & ! ,
& & & & ! & "& -
&
- - & ! & - * ) & ! & & !
& - & # - ,
= & & & & A - # & ! " & ) & & # & !
NN- ! " # - # ) & ! - ! J
& A - # & ! QNN - & & & & ! & &
# & ! ) # - & ) # & - "& )
& - # ) & & ! &
= & & - & & ! "& & ! # & - & & ! -
6
6 6
6
! R + # % Q
! R + # % Q ! R + # % Q
! R + # % Q @
@@
@& & %
& & % & & %
& & %
& ! ! R * & ! & " & ! & " & ! & ! ,
PHP/CURL Book with Examples
: 4! &
! R & &
! R & & ! R & &
! R & &
% - & & ! R & &
* + & ! R ,/ ) & - & & " ! R
- ! & =& & & ! - & "& )
& - ) - # ! % )
<?php
// Example reg001.php
// Simple Regular Expressions in PHP
// Copyright
// Match some sub text inside a text string.
// Example string
$str = "Let's find the Name :<B>Muhammad Imran</B> <table> some table</table>and
some fonts tags of </html>";
// Let's perform the regex
$flag = preg_match("/<B>(.*)<\/B>/", $str, $matches);
// Check if regex was successful
if ($flag = true) {
// Matched something, show the matched string
echo htmlentities($matches['0']);
// Also how the text in between the tags
echo '<br />' . $matches['1'];
} else {
// No Match
echo "Couldn't find a match";
}
?>
/ % & ! & - "J # # ) ! - - =- ? & !
- ) " # % - & & &
! R ! & ) ! & # # )
&
& - ! & # E & ! = & - & & & !
( & ) "- ! & & # & "# ) & ! - "
& # & & ! "J ! - -
PHP/CURL Book with Examples
! R R & &
! R R & & ! R R & &
! R R & &
! R & & & - = ) & & -
/ & & ! ") & - ! R R & &
* + & ! R R ,
<?php
// Example reg002.php
// Simple Regular Expressions in PHP
// Copyright
// parsing name, email from hotmail contact html page.
// using php function preg_match_all
$str = '
<html>
<body>
<table border=0 cellpadding=0 cellspacing=0 width=100% class="EE"
id="ListTable">
<form name=doaddy action="/cgi-bin/doaddresses" method=POST>
<input type=hidden name="" value="">
<input type=hidden name=_HMaction value="">
<input type=hidden name=i>
<input type=hidden name=IsGroup>
<input type=hidden name=strUsrFltr value="">
<input type=hidden name=strUsrView value="">
<input type=hidden name=strAlphNav value="">
<input type=hidden name=a value=0aee4eac7ebe5d67fa50eb5267e959b02e
b61cb9ba63cb9598857c5a311822e5>
<tr height=26>
<td colspan=6 align=right style="BORDER-TOP:none;COLOR:#8D8D8D">
<font class="K">ALL</font> # A B <a href="java
script:AN("","","C")">C</a> D E F G H I 
;J <a href="javascript:AN("","","K")">K</a> L M N 
;O P Q R S T U V W X Y&n
bsp;Z </td>
</tr>
<tr id="messPrompt">
</tr>
<tr bgcolor=#DBEAF5>
<td width=1% height=24 align=center> <input name=allbox type=
checkbox onClick="CA()"> </td>
<td width=1%> </td>
<td bgcolor=#A0C6E5>
<a href="javascript:AD("addrrev=1&addrsort=nick&strUsrFltr=&strUsr
View=&strAlphNav=")" title="Sort by Name" class="FF">
<img src=" hspace=3 borde
r=0 alt="sorted in ascending order">Name</a>
</td>
<td >
<a href="javascript:AD("addrrev=1&addrsort=email&strUsrFltr=&strUs
rView=&strAlphNav=")" title="Sort by E-Mail" class="FF">E-Mail</a>
</td>
<td>
<font class="FF">Phone</font>
</td>
</tr>
<tr name="" id="13bf6320-da8e-4d40-8759-3c4ab27e36a0">
<td align=center>
PHP/CURL Book with Examples
<input type=checkbox name="ADDR13bf6320-da8e-4d40-8759-
3c4ab27e36a0" onClick="CCA(this)" id="hotmail">
</td>
<td width=1%>
</td>
<td nowap>
<a href="#" onclick="javascript:DoAD("","&strUsrView=",event);retu
rn false;">cheema</a>
</td>
<td>
<a href="#" onclick="javascript:DC(event);return false;">cheema@gm
ail.com</a>
</td>
<td>
</td>
</tr>
<tr name="" id="2b151594-b7ed-4994-8953-44ace5bfc483">
<td align=center>
<input type=checkbox name="ADDR2b151594-b7ed-4994-8953-
44ace5bfc483" onClick="CCA(this)" id="hotmail">
</td>
<td width=1%>
</td>
<td nowap>
<a href="#" onclick="javascript:DoAD("","&strUsrView=",event);retu
rn false;">kahlid</a>
</td>
<td>
<a href="#" onclick="javascript:DC(event);return false;">khalid@ya
hoo.com</a>
</td>
<td>
</td>
</tr>
<tr name="" id="e7615392-aac4-45e2-87e8-96afa21eb928">
<td align=center>
<input type=checkbox name="ADDRe7615392-aac4-45e2-87e8-
96afa21eb928" onClick="CCA(this)" id="hotmail">
</td>
<td width=1%>
</td>
<td nowap>
<a href="#" onclick="javascript:DoAD("","&strUsrView=",event);retu
rn false;">khalid, imran</a>
</td>
<td>
<a href="#" onclick="javascript:DC(event);return false;">imran@hot
mail.com</a>
</td>
<td>
</td>
</tr>
<td colspan=5> </td>
</table>
</td>
<tr>
</table>