<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>飞扬轻狂&#039;s blog &#187; php</title>
	<atom:link href="http://blog.fallseir.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.fallseir.com</link>
	<description>我心飞扬 我意轻狂</description>
	<lastBuildDate>Thu, 06 May 2010 07:13:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/><cloud domain='blog.fallseir.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>php的多分支控制</title>
		<link>http://blog.fallseir.com/2009/04/php_more_ifelse/</link>
		<comments>http://blog.fallseir.com/2009/04/php_more_ifelse/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 06:57:32 +0000</pubDate>
		<dc:creator>飞扬轻狂</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[小代码]]></category>

		<guid isPermaLink="false">http://blog.fallseir.com/?p=129</guid>
		<description><![CDATA[php的多分支控制 &#8211; 原文 (飞扬轻狂,fallseir) 20090427 ==== php的多分支控制 ==== ### if 方式 实现多分支控制 if(runStep(1)){ if(runStep(2)){ if(runStep(3)){ # all steps are success!! }else{ # step 03 is failed! } }else{ # step 03 is failed! } }else{ # step 03 is failed! } # some others steps ### if 方式 2 实现多分支控制 $r=0; if(runStep(1)) if(runStep(2)) if(runStep(3)) else [...]]]></description>
			<content:encoded><![CDATA[<p>php的多分支控制<br />
&#8211; <a href="http://blog.fallseir.com/2009/04/php_more_ifelse/">原文</a> (飞扬轻狂,fallseir) 20090427<br />
==== php的多分支控制 ====<br />
### if 方式 实现多分支控制</p>
<pre>
if(runStep(1)){
  if(runStep(2)){
    if(runStep(3)){
      # all steps are success!!
    }else{
	# step 03 is failed!
    }
  }else{
    # step 03 is failed!
  }
}else{
  # step 03 is failed!
}

# some others steps
</pre>
<p>### if 方式 2 实现多分支控制</p>
<pre>
$r=0;
if(runStep(1))
  if(runStep(2))
    if(runStep(3))
    else $r=3;
  else $r=2;
else $r=1;
if($r){
  # step $r is failed!
  return false;
}

# some others steps
</pre>
<p>### do..while(false) 方式 2 实现多分支控制</p>
<pre>
do{
  if(!runStep(1)) # step 01 is failed!
  break;
  if(!runStep(2)) # step 02 is failed!
  break;
  if(!runStep(3)) # step 03 is failed!
  break;
  # all steps are success!!
}while(false);

# some others steps
</pre>
<p>### switch(true) 方式 2 实现多分支控制</p>
<pre>
switch(true){
  case !runStep(1):
	# step 01 is failed!
	break;
  case !runStep(2):
	# step 02 is failed!
	break;
  case !runStep(3):
	# step 03 is failed!
	break;
  default:
	# all steps are success!!
    break;
}

# some others steps
</pre>
<p>### try..catch 方式实现</p>
<pre>
try{
  if(!runStep(1)) throw new SomeError(1); # step 01 is failed!
  if(!runStep(2)) throw new SomeError(2); # step 02 is failed!
  if(!runStep(3)) throw new SomeError(3); # step 01 is failed!
  # all steps are success!!
}catch(SomeError $ex){
  # step $ex is failed!
  return false;
}
# some others steps
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.fallseir.com/2009/04/php_more_ifelse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用反射 实现的 简单的 单元测试框架</title>
		<link>http://blog.fallseir.com/2009/04/php_simple_unit_test/</link>
		<comments>http://blog.fallseir.com/2009/04/php_simple_unit_test/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 06:37:06 +0000</pubDate>
		<dc:creator>飞扬轻狂</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[unit test]]></category>
		<category><![CDATA[小代码]]></category>

		<guid isPermaLink="false">http://blog.fallseir.com/?p=127</guid>
		<description><![CDATA[使用反射 实现的 简单的 单元测试框架 &#8211; 原文 (飞扬轻狂,fallseir) 20090427 ==== generalized test methods use introspection ==== class customClass{ function selfTest(){[..] return [message&#124;false]} } class tester{ function test($thing){ if(is_object($thing)){ if(method_exists($thing,'selfTest')){ $this->handleTest(call_user_method('selfTest',$thing)); } }else if(is_array($thing)){ foreach($thing as $component){ $this->test($component); } }else{ ;//ignore if not an array or object } } function handleTest($result){if($result)print "Warning $result";} } 参考: John.Wiley.and.Sons.PHP5.and.MySQL.Bible]]></description>
			<content:encoded><![CDATA[<p>使用反射 实现的 简单的 单元测试框架<br />
&#8211; <a href="http://blog.fallseir.com/2009/04/php_simple_unit_test/">原文</a> (飞扬轻狂,fallseir) 20090427<br />
==== generalized test methods use introspection ====</p>
<pre>
class customClass{
  function selfTest(){[..] return [message|false]}
}
class tester{
  function test($thing){
    if(is_object($thing)){
      if(method_exists($thing,'selfTest')){
        $this->handleTest(call_user_method('selfTest',$thing));
      }
    }else if(is_array($thing)){
      foreach($thing as $component){ $this->test($component); }
    }else{
    ;//ignore if not an array or object
    }
  }
  function handleTest($result){if($result)print "Warning $result";}
}
</pre>
<p>参考:<br />
John.Wiley.and.Sons.PHP5.and.MySQL.Bible</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fallseir.com/2009/04/php_simple_unit_test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>一段用于替换字符串中指定的key的代码</title>
		<link>http://blog.fallseir.com/2008/05/mapkeys/</link>
		<comments>http://blog.fallseir.com/2008/05/mapkeys/#comments</comments>
		<pubDate>Tue, 06 May 2008 09:58:02 +0000</pubDate>
		<dc:creator>飞扬轻狂</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[fallseir]]></category>

		<guid isPermaLink="false">http://blog.fallseir.com/?p=89</guid>
		<description><![CDATA[一段用于替换字符串中指定的key的代码 &#8211;[[User:Fallseir&#124;飞扬轻狂]] 2008年5月6日 (二) 02:32 (PDT) $str=mapKeys($formatstr,$maps); $str=&#8220;replace&#160;this&#160;template&#160;string&#160;!the&#160;key&#160;maps&#160;is&#160;herekey1=&#62;{key1},key{{2=&#62;{key{2},key3}=&#62;{key3{}}&#8221;;echo&#160;mapKeys($str&#160;&#160;,array(&#8220;key1&#8243;=&#62;&#8220;value&#160;1&#8243;&#160;&#160;,&#8220;key{2&#8243;=&#62;&#8220;value&#160;2&#8243;&#160;&#160;,&#8220;key3}&#8221;=&#62;&#8220;value&#160;3&#8243;&#160;&#160;));echo&#160;&#8220;\n&#8221; output>> replace this template string !the key maps is here key1=>value 1,key{2=>value 2,key3}=>value 3 abc[the abc value]}}%[%}%%%]%{%[0}%%,%%%,{key],%%,%%[the %value% 2],%%[the %value% 2],%$$%%{,%, abc%%%%%%%%%,%%%,%key%,%%,%%%key,2%,%,%$$%%,%, $ php -r &#8216;highlight_file(&#8220;test.php&#8221;);&#8217; &#60;?php/**&#160;test&#160;*/$str="replace&#160;this&#160;template&#160;string&#160;!the&#160;key&#160;maps&#160;is&#160;herekey1=&#62;{key1},key{{2=&#62;{key{2},key3}=&#62;{key3{}}";echo&#160;mapKeys($str&#160;&#160;,array("key1"=&#62;"value&#160;1"&#160;&#160;,"key{2"=&#62;"value&#160;2"&#160;&#160;,"key3}"=&#62;"value&#160;3"&#160;&#160;));echo&#160;"\n"; $str="abc{key}{}}%{%{}%%%}%{{%{0{}%%,%%%,{key},%%,%%{key,2},%%{key,2},%$$%%{,%,";echo&#160;mapKeys($str,array("key"=&#62;"[the&#160;abc&#160;value]","key,2"=&#62;"[the&#160;%value%&#160;2]"));echo&#160;"\n"; $str="abc%%%%%%%%%,%%%,%key%,%%,%%%key,2%,%,%$$%%,%,";echo&#160;mapKeys($str,array("key"=&#62;"[the&#160;abc&#160;value]"&#160;&#160;&#160;&#160;,"key,2"=&#62;"[the&#160;%value%&#160;2]"),"&#124;%&#124;");echo&#160;"\n";//end&#160;test*//*$&#160;php&#160;test.phpoutput&#62;&#62;replace&#160;this&#160;template&#160;string&#160;!the&#160;key&#160;maps&#160;is&#160;herekey1=&#62;value&#160;1,key{2=&#62;value&#160;2,key3}=&#62;value&#160;3abc[the&#160;abc&#160;value]}}%[%}%%%]%{%[0}%%,%%%,{key],%%,%%[the&#160;%value%&#160;2],%%[the&#160;%value%&#160;2],%$$%%{,%,abc%%%%%%%%%,%%%,%key%,%%,%%%key,2%,%,%$$%%,%,&#160;&#160;*/&#160;&#160;/**&#160;*&#160;使用maps中定义的value替换对应其key的由开始标记字符和结束标记字符包含的字符串&#160;*&#160;*&#160;当标记对外开始标记后跟着开始标记时或结束标记时表示第一个开始标记为转义符&#160;*&#160;当标记对内开始标记后跟着结束标记时表示第一个开始标记为转义符&#160;*&#160;末尾没有匹配的开始标记将原样输出&#160;*/function&#160;mapKeys($str,$maps,$fstart=null,$fend=null){&#160;&#160;if(!$fstart){&#160;&#160;&#160;&#160;&#160;&#160;$fstart="{";&#160;&#160;&#160;&#160;&#160;&#160;$fend="}";&#160;&#160;}&#160;&#160;if(!$fend){&#160;&#160;&#160;&#160;$fend=$fstart;&#160;&#160;&#160;&#160;&#160;&#160;}&#160;&#160;&#160;&#160;//&#160;如果标记相同则使用mapKeysBase进行替换&#160;&#160;if($fstart==$fend){return&#160;mapKeysBase($str,$maps,$fstart);}&#160;&#160;&#160;$index=0;&#160;&#160;$offset=0;&#160;&#160;while(false!==($index=strpos($str,$fstart,$offset))){&#160;&#160;&#160;&#160;#&#160;找到开始标记,处理开始标记之前的数据&#160;&#160;&#160;&#160;$v=substr($str,$offset,$index-$offset);&#160;&#160;&#160;&#160;$offset=$index+strlen($fstart);&#160;&#160;&#160;&#160;$p=true;&#160;&#160;&#160;&#160;while(($find=substr($str,$offset,strlen($fstart)))==$fstart&#160;&#160;&#160;&#160;&#160;&#160;&#124;&#124;($find=substr($str,$offset,strlen($fend)))==$fend){&#160;&#160;&#160;&#160;&#160;&#160;$v.=$find;&#160;&#160;&#160;&#160;&#160;&#160;$offset=$offset+strlen($find);&#160;&#160;&#160;&#160;&#160;&#160;$p=false;#&#160;如果这个标记是用来转义的&#160;&#160;&#160;&#160;&#160;&#160;if(false!==($index=strpos($str,$fstart,$offset))){&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$v.=substr($str,$offset,$index-$offset);&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$offset=$index+strlen($fstart);&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$p=true;#&#160;查找下一个开始标记&#160;&#160;&#160;&#160;&#160;&#160;}&#160;&#160;&#160;&#160;}&#160;&#160;&#160;&#160;$o.=$v;&#160;&#160;&#160;&#160;$v="";&#160;&#160;&#160;&#160;#&#160;标记了开始&#160;并找到了&#160;结束&#160;&#160;&#160;&#160;while($p&#160;&#160;&#160;&#160;&#160;&#160;&#38;&#38;false!==($end=strpos($str,$fend,$offset))){&#160;&#160;&#160;&#160;&#160;&#160;$v.=substr($str,$offset,$end-$offset);&#160;&#160;&#160;&#160;&#160;&#160;#&#160;如果这个标记是被转义的&#160;&#160;&#160;&#160;&#160;&#160;if(($find=substr($str,$end-strlen($fend),strlen($fstart)))&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;==$fstart){&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$v=substr($v,0,strlen($v)-strlen($fstart)).$fend;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$offset=$end+strlen($fend);&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;continue;&#160;&#160;&#160;&#160;&#160;&#160;}&#160;&#160;&#160;&#160;&#160;&#160;$p=false;&#160;&#160;&#160;&#160;}&#160;&#160;&#160;&#160;if($v){&#160;&#160;&#160;&#160;&#160;&#160;if(array_key_exists($v,$maps)){&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$v=$maps[$v];&#160;&#160;&#160;&#160;&#160;&#160;}else{&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$v="[".$v."]";&#160;&#160;&#160;&#160;&#160;&#160;}&#160;&#160;&#160;&#160;&#160;&#160;$o.=$v;&#160;&#160;&#160;&#160;&#160;&#160;$offset=$end+strlen($fend);&#160;&#160;&#160;&#160;}&#160;&#160;}&#160;&#160;if($p){&#160;&#160;&#160;&#160;$o.=$fstart;&#160;&#160;}&#160;&#160;$v=substr($str,$offset);&#160;&#160;$o.=$v;&#160;&#160;return&#160;$o;}/**&#160;*&#160;使用maps中定义的value替换对应其key的由标记字符包含的字符串&#160;*&#160;*&#160;如果标记重复出现&#160;则第一个为转义字符（这也意味着标记字符不能作为key的开始字符）&#160;*/function&#160;mapKeysBase($str,$maps,$find=null){&#160;&#160;if(!$find){&#160;&#160;&#160;&#160;$find="%";&#160;&#160;}&#160;&#160;$p=false;&#160;&#160;$v="";&#160;&#160;$index=0;&#160;&#160;$offset=0;&#160;&#160;while(false!==($index=strpos($str,$find,$offset))){&#160;&#160;&#160;&#160;$v.=substr($str,$offset,$index-$offset);&#160;&#160;&#160;&#160;$offset=$index+strlen($find);&#160;&#160;&#160;&#160;while(substr($str,$offset,strlen($find))==$find){&#160;&#160;&#160;&#160;&#160;&#160;$v.=$find;&#160;&#160;&#160;&#160;&#160;&#160;$offset=$offset+strlen($find);&#160;&#160;&#160;&#160;&#160;&#160;if(false!==($index=strpos($str,$find,$offset))){&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$v.=substr($str,$offset,$index-$offset);&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$offset=$index+strlen($find);&#160;&#160;&#160;&#160;&#160;&#160;}&#160;&#160;&#160;&#160;}&#160;&#160;&#160;&#160;if($p){&#160;&#160;&#160;&#160;&#160;&#160;if(array_key_exists($v,$maps)){&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$v=$maps[$v];&#160;&#160;&#160;&#160;&#160;&#160;}else{&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$v="[".$v."]";&#160;&#160;&#160;&#160;&#160;&#160;}&#160;&#160;&#160;&#160;&#160;&#160;$o.=$v;&#160;&#160;&#160;&#160;&#160;&#160;$v="";&#160;&#160;&#160;&#160;&#160;&#160;$p=false;&#160;&#160;&#160;&#160;}else{&#160;&#160;&#160;&#160;&#160;&#160;$o.=$v;&#160;&#160;&#160;&#160;&#160;&#160;$v="";&#160;&#160;&#160;&#160;&#160;&#160;$p=true;&#160;&#160;&#160;&#160;}&#160;&#160;}&#160;&#160;if($p){&#160;&#160;&#160;&#160;$v.=$find;&#160;&#160;}&#160;&#160;$v.=substr($str,$offset);&#160;&#160;$o.=$v;&#160;&#160;return&#160;$o;}?&#62; 取自&#8221;http://www.fallseir.com/wiki/PHP/MapKeys.html&#8221;]]></description>
			<content:encoded><![CDATA[<p>一段用于替换字符串中指定的key的代码</p>
<p>&#8211;[[User:Fallseir|飞扬轻狂]] 2008年5月6日 (二) 02:32 (PDT)<br />
$str=mapKeys($formatstr,$maps);</p>
<p><span style="color: #0000BB">$str</span><span style="color: #007700">=</span><span style="color: #DD0000">&#8220;replace&nbsp;this&nbsp;template&nbsp;string&nbsp;!the&nbsp;key&nbsp;maps&nbsp;is&nbsp;here<br />key1=&gt;{key1},key{{2=&gt;{key{2},key3}=&gt;{key3{}}&#8221;</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">mapKeys</span><span style="color: #007700">(</span><span style="color: #0000BB">$str<br />&nbsp;&nbsp;</span><span style="color: #007700">,array(</span><span style="color: #DD0000">&#8220;key1&#8243;</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">&#8220;value&nbsp;1&#8243;<br />&nbsp;&nbsp;</span><span style="color: #007700">,</span><span style="color: #DD0000">&#8220;key{2&#8243;</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">&#8220;value&nbsp;2&#8243;<br />&nbsp;&nbsp;</span><span style="color: #007700">,</span><span style="color: #DD0000">&#8220;key3}&#8221;</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">&#8220;value&nbsp;3&#8243;<br />&nbsp;&nbsp;</span><span style="color: #007700">)<br />);<br />echo&nbsp;</span><span style="color: #DD0000">&#8220;\n&#8221;</span></p>
<p>output>><br />
replace this template string !the key maps is here<br />
key1=>value 1,key{2=>value 2,key3}=>value 3<br />
abc[the abc value]}}%[%}%%%]%{%[0}%%,%%%,{key],%%,%%[the %value% 2],%%[the %value% 2],%$$%%{,%,<br />
abc%%%%%%%%%,%%%,%key%,%%,%%%key,2%,%,%$$%%,%,</p>
<p>$ php -r &#8216;highlight_file(&#8220;test.php&#8221;);&#8217;</p>
<p><code><span style="color: #000000"><br />
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/**&nbsp;test&nbsp;*/<br /></span><span style="color: #0000BB">$str</span><span style="color: #007700">=</span><span style="color: #DD0000">"replace&nbsp;this&nbsp;template&nbsp;string&nbsp;!the&nbsp;key&nbsp;maps&nbsp;is&nbsp;here<br />key1=&gt;{key1},key{{2=&gt;{key{2},key3}=&gt;{key3{}}"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">mapKeys</span><span style="color: #007700">(</span><span style="color: #0000BB">$str<br />&nbsp;&nbsp;</span><span style="color: #007700">,array(</span><span style="color: #DD0000">"key1"</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">"value&nbsp;1"<br />&nbsp;&nbsp;</span><span style="color: #007700">,</span><span style="color: #DD0000">"key{2"</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">"value&nbsp;2"<br />&nbsp;&nbsp;</span><span style="color: #007700">,</span><span style="color: #DD0000">"key3}"</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">"value&nbsp;3"<br />&nbsp;&nbsp;</span><span style="color: #007700">)<br />);<br />echo&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;</p>
<p></span><span style="color: #0000BB">$str</span><span style="color: #007700">=</span><span style="color: #DD0000">"abc{key}{}}%{%{}%%%}%{{%{0{}%%,%%%,{key},%%,%%{key,2},%%{key,2},%$$%%{,%,"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">mapKeys</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,array(</span><span style="color: #DD0000">"key"</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">"[the&nbsp;abc&nbsp;value]"<br /></span><span style="color: #007700">,</span><span style="color: #DD0000">"key,2"</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">"[the&nbsp;%value%&nbsp;2]"</span><span style="color: #007700">));<br />echo&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;</p>
<p></span><span style="color: #0000BB">$str</span><span style="color: #007700">=</span><span style="color: #DD0000">"abc%%%%%%%%%,%%%,%key%,%%,%%%key,2%,%,%$$%%,%,"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">mapKeys</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,array(</span><span style="color: #DD0000">"key"</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">"[the&nbsp;abc&nbsp;value]"<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">,</span><span style="color: #DD0000">"key,2"</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">"[the&nbsp;%value%&nbsp;2]"</span><span style="color: #007700">),</span><span style="color: #DD0000">"|%|"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">//end&nbsp;test*/<br />/*<br />$&nbsp;php&nbsp;test.php<br />output&gt;&gt;<br />replace&nbsp;this&nbsp;template&nbsp;string&nbsp;!the&nbsp;key&nbsp;maps&nbsp;is&nbsp;here<br />key1=&gt;value&nbsp;1,key{2=&gt;value&nbsp;2,key3}=&gt;value&nbsp;3<br />abc[the&nbsp;abc&nbsp;value]}}%[%}%%%]%{%[0}%%,%%%,{key],%%,%%[the&nbsp;%value%&nbsp;2],%%[the&nbsp;%value%&nbsp;2],%$$%%{,%,<br />abc%%%%%%%%%,%%%,%key%,%%,%%%key,2%,%,%$$%%,%,<br />&nbsp;<br />&nbsp;*/<br />&nbsp;<br />&nbsp;<br />/**<br />&nbsp;*&nbsp;使用maps中定义的value替换对应其key的由开始标记字符和结束标记字符包含的字符串<br />&nbsp;*<br />&nbsp;*&nbsp;当标记对外开始标记后跟着开始标记时或结束标记时表示第一个开始标记为转义符<br />&nbsp;*&nbsp;当标记对内开始标记后跟着结束标记时表示第一个开始标记为转义符<br />&nbsp;*&nbsp;末尾没有匹配的开始标记将原样输出<br />&nbsp;*/<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">mapKeys</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$maps</span><span style="color: #007700">,</span><span style="color: #0000BB">$fstart</span><span style="color: #007700">=</span><span style="color: #0000BB">null</span><span style="color: #007700">,</span><span style="color: #0000BB">$fend</span><span style="color: #007700">=</span><span style="color: #0000BB">null</span><span style="color: #007700">){<br />&nbsp;&nbsp;if(!</span><span style="color: #0000BB">$fstart</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$fstart</span><span style="color: #007700">=</span><span style="color: #DD0000">"{"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$fend</span><span style="color: #007700">=</span><span style="color: #DD0000">"}"</span><span style="color: #007700">;<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;if(!</span><span style="color: #0000BB">$fend</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$fend</span><span style="color: #007700">=</span><span style="color: #0000BB">$fstart</span><span style="color: #007700">;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;如果标记相同则使用mapKeysBase进行替换<br />&nbsp;&nbsp;</span><span style="color: #007700">if(</span><span style="color: #0000BB">$fstart</span><span style="color: #007700">==</span><span style="color: #0000BB">$fend</span><span style="color: #007700">){return&nbsp;</span><span style="color: #0000BB">mapKeysBase</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$maps</span><span style="color: #007700">,</span><span style="color: #0000BB">$fstart</span><span style="color: #007700">);}<br />&nbsp;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$index</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$offset</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />&nbsp;&nbsp;while(</span><span style="color: #0000BB">false</span><span style="color: #007700">!==(</span><span style="color: #0000BB">$index</span><span style="color: #007700">=</span><span style="color: #0000BB">strpos</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$fstart</span><span style="color: #007700">,</span><span style="color: #0000BB">$offset</span><span style="color: #007700">))){<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#&nbsp;找到开始标记,处理开始标记之前的数据<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">=</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$offset</span><span style="color: #007700">,</span><span style="color: #0000BB">$index</span><span style="color: #007700">-</span><span style="color: #0000BB">$offset</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$offset</span><span style="color: #007700">=</span><span style="color: #0000BB">$index</span><span style="color: #007700">+</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$fstart</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">=</span><span style="color: #0000BB">true</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;while((</span><span style="color: #0000BB">$find</span><span style="color: #007700">=</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$offset</span><span style="color: #007700">,</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$fstart</span><span style="color: #007700">)))==</span><span style="color: #0000BB">$fstart<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">||(</span><span style="color: #0000BB">$find</span><span style="color: #007700">=</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$offset</span><span style="color: #007700">,</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$fend</span><span style="color: #007700">)))==</span><span style="color: #0000BB">$fend</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">.=</span><span style="color: #0000BB">$find</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$offset</span><span style="color: #007700">=</span><span style="color: #0000BB">$offset</span><span style="color: #007700">+</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$find</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">=</span><span style="color: #0000BB">false</span><span style="color: #007700">;</span><span style="color: #FF8000">#&nbsp;如果这个标记是用来转义的<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if(</span><span style="color: #0000BB">false</span><span style="color: #007700">!==(</span><span style="color: #0000BB">$index</span><span style="color: #007700">=</span><span style="color: #0000BB">strpos</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$fstart</span><span style="color: #007700">,</span><span style="color: #0000BB">$offset</span><span style="color: #007700">))){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">.=</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$offset</span><span style="color: #007700">,</span><span style="color: #0000BB">$index</span><span style="color: #007700">-</span><span style="color: #0000BB">$offset</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$offset</span><span style="color: #007700">=</span><span style="color: #0000BB">$index</span><span style="color: #007700">+</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$fstart</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">=</span><span style="color: #0000BB">true</span><span style="color: #007700">;</span><span style="color: #FF8000">#&nbsp;查找下一个开始标记<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$o</span><span style="color: #007700">.=</span><span style="color: #0000BB">$v</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">=</span><span style="color: #DD0000">""</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#&nbsp;标记了开始&nbsp;并找到了&nbsp;结束<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">while(</span><span style="color: #0000BB">$p<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">&amp;&amp;</span><span style="color: #0000BB">false</span><span style="color: #007700">!==(</span><span style="color: #0000BB">$end</span><span style="color: #007700">=</span><span style="color: #0000BB">strpos</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$fend</span><span style="color: #007700">,</span><span style="color: #0000BB">$offset</span><span style="color: #007700">))){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">.=</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$offset</span><span style="color: #007700">,</span><span style="color: #0000BB">$end</span><span style="color: #007700">-</span><span style="color: #0000BB">$offset</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">#&nbsp;如果这个标记是被转义的<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if((</span><span style="color: #0000BB">$find</span><span style="color: #007700">=</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$end</span><span style="color: #007700">-</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$fend</span><span style="color: #007700">),</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$fstart</span><span style="color: #007700">)))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==</span><span style="color: #0000BB">$fstart</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">=</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$v</span><span style="color: #007700">,</span><span style="color: #0000BB">0</span><span style="color: #007700">,</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$v</span><span style="color: #007700">)-</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$fstart</span><span style="color: #007700">)).</span><span style="color: #0000BB">$fend</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$offset</span><span style="color: #007700">=</span><span style="color: #0000BB">$end</span><span style="color: #007700">+</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$fend</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">=</span><span style="color: #0000BB">false</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: #0000BB">$v</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: #0000BB">array_key_exists</span><span style="color: #007700">(</span><span style="color: #0000BB">$v</span><span style="color: #007700">,</span><span style="color: #0000BB">$maps</span><span style="color: #007700">)){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">=</span><span style="color: #0000BB">$maps</span><span style="color: #007700">[</span><span style="color: #0000BB">$v</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">=</span><span style="color: #DD0000">"["</span><span style="color: #007700">.</span><span style="color: #0000BB">$v</span><span style="color: #007700">.</span><span style="color: #DD0000">"]"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$o</span><span style="color: #007700">.=</span><span style="color: #0000BB">$v</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$offset</span><span style="color: #007700">=</span><span style="color: #0000BB">$end</span><span style="color: #007700">+</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$fend</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;if(</span><span style="color: #0000BB">$p</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$o</span><span style="color: #007700">.=</span><span style="color: #0000BB">$fstart</span><span style="color: #007700">;<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">=</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$offset</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$o</span><span style="color: #007700">.=</span><span style="color: #0000BB">$v</span><span style="color: #007700">;<br />&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$o</span><span style="color: #007700">;<br />}<br /></span><span style="color: #FF8000">/**<br />&nbsp;*&nbsp;使用maps中定义的value替换对应其key的由标记字符包含的字符串<br />&nbsp;*<br />&nbsp;*&nbsp;如果标记重复出现&nbsp;则第一个为转义字符（这也意味着标记字符不能作为key的开始字符）<br />&nbsp;*/<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">mapKeysBase</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$maps</span><span style="color: #007700">,</span><span style="color: #0000BB">$find</span><span style="color: #007700">=</span><span style="color: #0000BB">null</span><span style="color: #007700">){<br />&nbsp;&nbsp;if(!</span><span style="color: #0000BB">$find</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$find</span><span style="color: #007700">=</span><span style="color: #DD0000">"%"</span><span style="color: #007700">;<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">=</span><span style="color: #0000BB">false</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">=</span><span style="color: #DD0000">""</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$index</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$offset</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />&nbsp;&nbsp;while(</span><span style="color: #0000BB">false</span><span style="color: #007700">!==(</span><span style="color: #0000BB">$index</span><span style="color: #007700">=</span><span style="color: #0000BB">strpos</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$find</span><span style="color: #007700">,</span><span style="color: #0000BB">$offset</span><span style="color: #007700">))){<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">.=</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$offset</span><span style="color: #007700">,</span><span style="color: #0000BB">$index</span><span style="color: #007700">-</span><span style="color: #0000BB">$offset</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$offset</span><span style="color: #007700">=</span><span style="color: #0000BB">$index</span><span style="color: #007700">+</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$find</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;while(</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$offset</span><span style="color: #007700">,</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$find</span><span style="color: #007700">))==</span><span style="color: #0000BB">$find</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">.=</span><span style="color: #0000BB">$find</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$offset</span><span style="color: #007700">=</span><span style="color: #0000BB">$offset</span><span style="color: #007700">+</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$find</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: #0000BB">false</span><span style="color: #007700">!==(</span><span style="color: #0000BB">$index</span><span style="color: #007700">=</span><span style="color: #0000BB">strpos</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$find</span><span style="color: #007700">,</span><span style="color: #0000BB">$offset</span><span style="color: #007700">))){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">.=</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$offset</span><span style="color: #007700">,</span><span style="color: #0000BB">$index</span><span style="color: #007700">-</span><span style="color: #0000BB">$offset</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$offset</span><span style="color: #007700">=</span><span style="color: #0000BB">$index</span><span style="color: #007700">+</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$find</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: #0000BB">$p</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: #0000BB">array_key_exists</span><span style="color: #007700">(</span><span style="color: #0000BB">$v</span><span style="color: #007700">,</span><span style="color: #0000BB">$maps</span><span style="color: #007700">)){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">=</span><span style="color: #0000BB">$maps</span><span style="color: #007700">[</span><span style="color: #0000BB">$v</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">=</span><span style="color: #DD0000">"["</span><span style="color: #007700">.</span><span style="color: #0000BB">$v</span><span style="color: #007700">.</span><span style="color: #DD0000">"]"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$o</span><span style="color: #007700">.=</span><span style="color: #0000BB">$v</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">=</span><span style="color: #DD0000">""</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">=</span><span style="color: #0000BB">false</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}else{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$o</span><span style="color: #007700">.=</span><span style="color: #0000BB">$v</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">=</span><span style="color: #DD0000">""</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">=</span><span style="color: #0000BB">true</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;if(</span><span style="color: #0000BB">$p</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">.=</span><span style="color: #0000BB">$find</span><span style="color: #007700">;<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">.=</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">,</span><span style="color: #0000BB">$offset</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$o</span><span style="color: #007700">.=</span><span style="color: #0000BB">$v</span><span style="color: #007700">;<br />&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$o</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;<br /></span><br /></span><br />
</code></p>
<p>取自&#8221;<a href="http://www.fallseir.com/wiki/PHP/MapKeys.html">http://www.fallseir.com/wiki/PHP/MapKeys.html</a>&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fallseir.com/2008/05/mapkeys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Win下出现apache无法启动的解决方式</title>
		<link>http://blog.fallseir.com/2008/05/apachestart/</link>
		<comments>http://blog.fallseir.com/2008/05/apachestart/#comments</comments>
		<pubDate>Tue, 06 May 2008 03:49:46 +0000</pubDate>
		<dc:creator>飞扬轻狂</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[XAMPP]]></category>

		<guid isPermaLink="false">http://blog.fallseir.com/?p=88</guid>
		<description><![CDATA[Win下出现apache无法启动的解决方式 使用xampp时，时常会遇到apache启动不了的情况，而xampp的控制面板有没有什么像样的提示 只有一个&#8221;Busy&#8230;&#8221; 但重启Win后，先启动apache就不会遇到问题。 但是事情总是有原因的，决定去查下，也许是xampp给的提示不足，而不是apache的问题， > cmd > d:\ > cd tools\xampp\apache\bin\ #我的apache安装位置 > httpd # apache的启动程序 (OS 10048)通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 : make_sock: c ould not bind to address 0.0.0.0:80 no listening sockets available, shutting down Unable to open logs # 找到原因了 原来是我的80端口被占用了 > netstat -ano # 查看网络状态 Proto Local Address Foreign Address State PID TCP 127.0.0.1:80 [...]]]></description>
			<content:encoded><![CDATA[<p>Win下出现apache无法启动的解决方式</p>
<p>使用xampp时，时常会遇到apache启动不了的情况，而xampp的控制面板有没有什么像样的提示 只有一个&#8221;Busy&#8230;&#8221; </p>
<p>但重启Win后，先启动apache就不会遇到问题。 </p>
<p>但是事情总是有原因的，决定去查下，也许是xampp给的提示不足，而不是apache的问题， </p>
<pre>
> cmd
> d:\
> cd tools\xampp\apache\bin\ #我的apache安装位置
> httpd # apache的启动程序

(OS 10048)通常每个套接字地址(协议/网络地址/端口)只允许使用一次。  : make_sock: c
ould not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
# 找到原因了 原来是我的80端口被占用了

> netstat -ano # 查看网络状态

  Proto  Local Address          Foreign Address        State           PID
  TCP    127.0.0.1:80           127.0.0.1:1920         CLOSE_WAIT      1112
  TCP    127.0.0.1:80           127.0.0.1:2016         CLOSE_WAIT      1112
  ...
# 通过 Local Address 中端口为80的行 可以看到 我的80端口被PID为1112的进程占用了

任务管理器>进程 / 工具栏 > 查看 > 选择列 在“PID(进程ID)”项上打勾
在进程列表中 查找PID为1112的进程
# 我这里是该死的迅雷 ！！
# 当然之前我还遇到过QQ的时候
ok 杀掉这个进程 或者关掉罪魁，启动Apache 道路终于通畅了！^_～
</pre>
<p>取自&#8221;<a href="http://www.fallseir.com/wiki/Win%E4%B8%8B%E5%87%BA%E7%8E%B0apache%E6%97%A0%E6%B3%95%E5%90%AF%E5%8A%A8%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E5%BC%8F.html">wiki:Win下出现apache无法启动的解决方式</a>&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fallseir.com/2008/05/apachestart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>尝试恢复因为重装了系统改变目录而导致不可用的xampp</title>
		<link>http://blog.fallseir.com/2008/04/xamppreinstall/</link>
		<comments>http://blog.fallseir.com/2008/04/xamppreinstall/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 05:52:47 +0000</pubDate>
		<dc:creator>飞扬轻狂</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[笔记]]></category>
		<category><![CDATA[XAMPP]]></category>

		<guid isPermaLink="false">http://blog.fallseir.com/?p=87</guid>
		<description><![CDATA[尝试恢复因为重装了系统改变目录而导致不可用的xampp 出自Fallseir&#8217;s Wiki 尝试恢复因为重装了系统改变目录而导致不可用的xamppPHP 1、恢复mysql * 查看mysql的启动项 xampp\mysql_start.bat mysql\bin\mysqld &#8211;defaults-file=mysql\bin\my.cnf &#8211;standalone &#8211;console * 修改mysql的配置 mysql\bin\my.cnf 更改其中的配置路径 socket = &#8220;C:/tools/develop/xampp/mysql/mysql.sock&#8221; socket = &#8220;C:/tools/develop/xampp/mysql/mysql.sock&#8221; basedir = &#8220;C:/tools/develop/xampp/mysql&#8221; tmpdir = &#8220;C:/tools/develop/xampp/tmp&#8221; datadir = &#8220;C:/tools/develop/xampp/mysql/data&#8221; * 打开xampp-control 开启mysql服务 ok！ 2、 恢复apache * 修改apache的配置文件 xampp\apache\conf\httpd.conf 更改其中的配置路径 ServerRoot &#8220;c:/tools/develop/xampp/apache&#8221; DocumentRoot &#8220;c:/tools/develop/xampp/htdocs&#8221; ScriptAlias /cgi-bin/ &#8220;C:/tools/develop/xampp/cgi-bin/&#8221; * 更改apache中的xampp的配置 xampp\apache\conf\extra\httpd-xampp.conf * 更改自己的web站点配置 xampp\apache\conf\extra\httpd-vhost.conf * [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.fallseir.com/wiki/%E5%B0%9D%E8%AF%95%E6%81%A2%E5%A4%8D%E5%9B%A0%E4%B8%BA%E9%87%8D%E8%A3%85%E4%BA%86%E7%B3%BB%E7%BB%9F%E6%94%B9%E5%8F%98%E7%9B%AE%E5%BD%95%E8%80%8C%E5%AF%BC%E8%87%B4%E4%B8%8D%E5%8F%AF%E7%94%A8%E7%9A%84xampp.html">尝试恢复因为重装了系统改变目录而导致不可用的xampp</a><br />
出自<a href="http://www.fallseir.com/wiki">Fallseir&#8217;s Wiki</a></p>
<p>尝试恢复因为重装了系统改变目录而导致不可用的xamppPHP</p>
<p>1、恢复mysql</p>
<p>    * 查看mysql的启动项 xampp\mysql_start.bat </p>
<blockquote><p>mysql\bin\mysqld &#8211;defaults-file=mysql\bin\my.cnf &#8211;standalone &#8211;console</p></blockquote>
<p>    * 修改mysql的配置 mysql\bin\my.cnf </p>
<blockquote><p>更改其中的配置路径<br />
 socket   = &#8220;C:/tools/develop/xampp/mysql/mysql.sock&#8221;<br />
 socket   = &#8220;C:/tools/develop/xampp/mysql/mysql.sock&#8221;<br />
 basedir  = &#8220;C:/tools/develop/xampp/mysql&#8221;<br />
 tmpdir   = &#8220;C:/tools/develop/xampp/tmp&#8221;<br />
 datadir  = &#8220;C:/tools/develop/xampp/mysql/data&#8221;
</p></blockquote>
<p>    * 打开xampp-control 开启mysql服务 ok！<br />
2、 恢复apache<br />
    * 修改apache的配置文件 xampp\apache\conf\httpd.conf </p>
<blockquote><p>更改其中的配置路径<br />
 ServerRoot &#8220;c:/tools/develop/xampp/apache&#8221;<br />
 DocumentRoot &#8220;c:/tools/develop/xampp/htdocs&#8221;<br />
 <Directory "c:/tools/develop/xampp/htdocs"><br />
 ScriptAlias /cgi-bin/ &#8220;C:/tools/develop/xampp/cgi-bin/&#8221;<br />
 <Directory "C:/tools/develop/xampp/cgi-bin">
</p></blockquote>
<p>    * 更改apache中的xampp的配置 </p>
<blockquote><p>xampp\apache\conf\extra\httpd-xampp.conf</p></blockquote>
<p>    * 更改自己的web站点配置 </p>
<blockquote><p>xampp\apache\conf\extra\httpd-vhost.conf</p></blockquote>
<p>    * 打开xampp-control 开启apache服务 ok！<br />
3、恢复php<br />
    * 修改php配置信息中的路径 </p>
<blockquote><p>xampp\apache\bin\php.ini</p></blockquote>
<p>    * 重启apache ok！ </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fallseir.com/2008/04/xamppreinstall/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
