PHP笔记
<?php//统计访问量
if(!@$fp=fopen("num.txt","r")){
echo "num.txt文件创建成功!<br>";
}
$num=@fgets($fp,12);
if($num=="")
$num=0;
$num++;
@fclose($fp);
$fp=fopen("num.txt","w");
fwrite($fp,$num);
echo "你是第 <font size='50' color='red'><b><i>".$num."</i></b></font> 个访问者";
fclose($fp);
?>
PHP操作XML
<?xml version="1.0"?> <resultset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <row> <field name="ID">1738552</field> <field name="ContactID">1673403</field> <field name="CCContactID" xsi:nil="true" /> <field name="SFContactID" xsi:nil="true" /> <field name="ContactType">32</field> <field name="ContactStatus">0</field> <field name="CustomerID">1100</field> <field name="MpUserID">0</field> <field name="CorpRepContactName" xsi:nil="true" /> <field name="CreatedTime">2015-11-18 14:23:43</field> <field name="CreatedBy">0</field> <field name="LastModifiedTime">2015-11-18 14:23:43</field> <field name="LastModifiedBy">-41153</field> <field name="DeletedTime" xsi:nil="true" /> <field name="Owner" xsi:nil="true" /> <field name="ApproveID">0</field> <field name="ApproveBy">-41153</field> <field name="ApproveStatus">3</field> <field name="ApproveComment" xsi:nil="true" /> <field name="EventID">0</field> <field name="Status">1</field> <field name="ContactName">李**</field> <field name="ContactMobile">1381****099</field> <field name="ContactEmail"></field> <field name="ContactTitle">财务经理</field> <field name="ContactPhone" xsi:nil="true" /> <field name="ContactComment" xsi:nil="true" /> <field name="GlobalAreaCode">+86</field> <field name="SourceType">0</field> </row> </resultset>
<?php
header("content-type:text/html; charset=utf-8");
$xml = simplexml_load_file("query_result.xml");
foreach($xml->row as $rows){
$a = (array)$rows;
//print_r(count($a['field']));
for($i = 0; $i < count($a['field']); $i++){
print($a['field'][$i]);
print("<br/>");
}
foreach($rows->field as $field){
//print_r($field);
$arr = (array)$field;
print_r($arr['@attributes']['name']);
print("<br/>");
}
break;
}
?>
1738552 1673403 32 0 1100 0 2015-11-18 14:23:43 0 2015-11-18 14:23:43 -41153 0 -41153 3 0 1 李** 1381****099 财务经理 +86 0 ID ContactID CCContactID SFContactID ContactType ContactStatus CustomerID MpUserID CorpRepContactName CreatedTime CreatedBy LastModifiedTime LastModifiedBy DeletedTime Owner ApproveID ApproveBy ApproveStatus ApproveComment EventID Status ContactName ContactMobile ContactEmail ContactTitle ContactPhone ContactComment GlobalAreaCode SourceType
积跬步以致千里,积小流以成江海。
2016年5月之前的博文发布于51cto,链接地址:shamrock.blog.51cto.com
2016年5月之后博文发布与cnblogs上。
Github地址 https://github.com/umgsai
Keep moving~!!!
2016年5月之前的博文发布于51cto,链接地址:shamrock.blog.51cto.com
2016年5月之后博文发布与cnblogs上。
Github地址 https://github.com/umgsai
Keep moving~!!!

浙公网安备 33010602011771号