<?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>勿慢牛 &#187; php</title>
	<atom:link href="http://klniu.com/post/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://klniu.com</link>
	<description>『勿慢牛个人博客』</description>
	<lastBuildDate>Fri, 06 Jan 2012 06:42:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>在php数组内使用定界符</title>
		<link>http://klniu.com/post/delimiter-used-in-php-array/</link>
		<comments>http://klniu.com/post/delimiter-used-in-php-array/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 03:17:35 +0000</pubDate>
		<dc:creator>勿慢牛</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://klniu.com/?p=723</guid>
		<description><![CDATA[php在数组内也可以使用定界符，这样就不怕赋值的字符串内有单双引号了，使用如下: $families = array &#40; &#34;Griffin&#34;=&#62;array &#40; &#34;Peter&#34; =&#62; &#60;&#60;&#60;EOT lasdfjlsdfjsldfjslfjslfs\jdf EOT , &#34;Lois&#34;, &#34;Megan&#34; &#41; &#41;;]]></description>
			<content:encoded><![CDATA[<p>php在数组内也可以使用定界符，这样就不怕赋值的字符串内有单双引号了，使用如下:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$families</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span>
<span style="color: #009900;">&#40;</span>
  <span style="color: #0000ff;">&quot;Griffin&quot;</span><span style="color: #339933;">=&gt;</span>array
  <span style="color: #009900;">&#40;</span>
  <span style="color: #0000ff;">&quot;Peter&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000cc; font-style: italic;">&lt;&lt;&lt;EOT
lasdfjlsdfjsldfjslfjslfs\jdf
EOT</span>
  <span style="color: #339933;">,</span>
  <span style="color: #0000ff;">&quot;Lois&quot;</span><span style="color: #339933;">,</span>
  <span style="color: #0000ff;">&quot;Megan&quot;</span>
  <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://klniu.com/post/delimiter-used-in-php-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cloudgamer无刷新上传文件的PHP版本修改</title>
		<link>http://klniu.com/post/php-post-files/</link>
		<comments>http://klniu.com/post/php-post-files/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 04:17:05 +0000</pubDate>
		<dc:creator>勿慢牛</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[上传]]></category>
		<category><![CDATA[多文件上传]]></category>

		<guid isPermaLink="false">http://livesdrop.com/post/php-post-files/</guid>
		<description><![CDATA[源文地址 /** 使用本程序之前，请修改php.ini中限制的单个文件最大容量 * upload_max_filesize = 20M //最大文件限制 * post_max_size = 20M //POST接收的最大限制,即所有上传文件的总量 * 并最好与程序中的单个文件限制相同，以免出现验证错误 * 本脚本文件编码为ANSI,建议修改为与其他文件一致的编码 * 请自行修改可以上传的文件类型 * 如果有需要，可以自行修改文件类型的验证方式，读文件开头的2字节，而不是通过后缀名 * @filesource csdn网友mengshan1986提供的php版本 * @changer klniuer * @site http://livesdrop.com **/ ?&#62; $sort=12; $f_type=strtolower(&#34;swf,jpg,rar,zip,7z,iso,gif&#34;);//设置可上传的文件类型 $file_size_max=20*1024*1024;//限制单个文件上传最大容量 $overwrite = 0;//是否允许覆盖相同文件,1:允许,0:不允许 $f_input=&#34;Files&#34;;//设置上传域名称 $_msg &#8230; <a href="http://klniu.com/post/php-post-files/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cnblogs.com/cloudgamer/archive/2008/10/20/1314766.html" target="_blank">源文地址</a></p>
<pre class="brush:php;">/** 使用本程序之前，请修改php.ini中限制的单个文件最大容量
 * upload_max_filesize = 20M //最大文件限制
 * post_max_size = 20M //POST接收的最大限制,即所有上传文件的总量
 * 并最好与程序中的单个文件限制相同，以免出现验证错误
 * 本脚本文件编码为ANSI,建议修改为与其他文件一致的编码
 * 请自行修改可以上传的文件类型
 * 如果有需要，可以自行修改文件类型的验证方式，读文件开头的2字节，而不是通过后缀名
 * @filesource csdn网友mengshan1986提供的php版本
 * @changer klniuer
 * @site http://livesdrop.com
 **/
?&gt;
$sort=12;
$f_type=strtolower(&quot;swf,jpg,rar,zip,7z,iso,gif&quot;);//设置可上传的文件类型
$file_size_max=20*1024*1024;//限制单个文件上传最大容量
$overwrite = 0;//是否允许覆盖相同文件,1:允许,0:不允许
$f_input=&quot;Files&quot;;//设置上传域名称
$_msg = &quot;&quot;;
if (isset($_FILES[$f_input])){ //如果文件总大小超过服务器POST限制，文件就没有上传至服务器，foreach就不会执行，返回客户端的会是一个空字符串，此处加入验证
  foreach($_FILES[$f_input][&quot;error&quot;] as $key =&gt; $error){
    $up_error=&quot;no&quot;;
    if ($error == UPLOAD_ERR_OK &amp;&amp; is_uploaded_file($_FILES[$f_input][&#39;tmp_name&#39;][$key])){ //加入安全验证
      $f_name=$_FILES[$f_input][&#39;name&#39;][$key];//获取上传源文件名
      $uploadfile=$uploaddir.strtolower(basename($f_name));
      $tmp_type=substr(strrchr($f_name,&quot;.&quot;),1);//获取文件扩展名
      $tmp_type=strtolower($tmp_type);
      if(!stristr($f_type,$tmp_type)){
        $_msg .= &quot;对不起,不能上传&quot;.$tmp_type.&quot;格式文件, &quot;.$f_name.&quot; 文件上传失败!\\n&quot;;
        $up_error=&quot;yes&quot;;
      }elseif ($_FILES[$f_input][&#39;size&#39;][$key]&gt;$file_size_max){
        $_msg .= &quot;对不起,你上传的文件 &quot;.$f_name.&quot; 容量为&quot;.round($_FILES[$f_input][&#39;size&#39;][$key]/1024/1024,1).&quot;MB,大于限制的&quot;. round($file_size_max/1024/1024,1).&quot;MB,上传失败!\\n&quot;;
        $up_error=&quot;yes&quot;;
      }elseif (file_exists($uploadfile) &amp;&amp; !$overwrite){
        $_msg .= &quot;对不起,文件 &quot;.$f_name.&quot; 已经存在,上传失败!\\n&quot;;
        $up_error=&quot;yes&quot;;
      }else{//不需要随机数
        $t=date(&quot;ymdHis&quot;).substr($gettime[0],2,6).$rand;
        $attdir=&quot;file/&quot;;//将文件移至的目录，请根据自己情况修改，相对于该脚本路径
        if(!is_dir($attdir))
          mkdir($attdir);
        $uploadfile=$attdir.$t.&quot;.&quot;.$tmp_type;
        if(($up_error!=&quot;yes&quot;) and (move_uploaded_file($_FILES[$f_input][&#39;tmp_name&#39;][$key], $uploadfile))){
          $_msg .=$f_name.&#39; 上传成功\\n&#39;;
        }else{
          $_msg .=$f_name.&#39; 上传失败\\n&#39;;
        }
      }
    }elseif($error == UPLOAD_ERR_INI_SIZE){//调试使用，防止自己忘记更改upload_max_filesize 最大文件限制
      $msg .= &quot;对不起,文件大小超过服务器限制，请通知管理员。\\n&quot;;
    }else{
      $msg .= &quot;对不起,上传不可意料错误!\\n&quot;;
    }
  }
}else{
  $_msg .= &quot;对不起,文件大小超过限制！\\n&quot;;//如果上传上来的文件为空，则判断文件超过限制大小
}
echo &quot;&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--mce:0--&gt;&lt;/script&gt;&quot;;
?&gt;</pre>
<p>完整程序：<a href="http://www.boxcn.net/shared/fur3frt2zd" target="_blank">http://www.boxcn.net/shared/fur3frt2zd</a></p>
]]></content:encoded>
			<wfw:commentRss>http://klniu.com/post/php-post-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP大文件上传问题</title>
		<link>http://klniu.com/post/php-upload-large-file/</link>
		<comments>http://klniu.com/post/php-upload-large-file/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 02:14:36 +0000</pubDate>
		<dc:creator>勿慢牛</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[大文件上传]]></category>

		<guid isPermaLink="false">http://livesdrop.com/post/php-upload-large-file/</guid>
		<description><![CDATA[PHP上传大文件，除了修改 ; Maximum allowed size for uploaded files. upload_max_filesize = 20M 此外，还应该修改POST的限制 ; Maximum size of POST data that PHP will accept. post_max_size = 20M 而且两个最好一样，就不会出现验证不一致的现象。]]></description>
			<content:encoded><![CDATA[<p>PHP上传大文件，除了修改</p>
<pre class="brush:plain;">; Maximum allowed size for uploaded files.
upload_max_filesize = 20M</pre>
<p>此外，还应该修改POST的限制</p>
<pre class="brush:plain;">; Maximum size of POST data that PHP will accept.
post_max_size = 20M</pre>
<p>而且两个最好一样，就不会出现验证不一致的现象。</p>
]]></content:encoded>
			<wfw:commentRss>http://klniu.com/post/php-upload-large-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP表单中整数和浮点数的验证</title>
		<link>http://klniu.com/post/php-int-float-check/</link>
		<comments>http://klniu.com/post/php-int-float-check/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 08:20:28 +0000</pubDate>
		<dc:creator>勿慢牛</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[float]]></category>
		<category><![CDATA[int]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[表单]]></category>
		<category><![CDATA[验证]]></category>

		<guid isPermaLink="false">http://livesdrop.com/post/php-int-float-check/</guid>
		<description><![CDATA[PHP对于表单中提交的数据，因为默认为字符串的关系，所以不能使用is_int和is_float来验证来源数据是否正确。不过可以用一个折中的方法来验证，代码如下： if((string)(int)$data===(string)$data) return true; if((string)(float)$data===(string)$data) return true; 原理是变为float或者int的字符串，前置0为自动清除。三个等号保证php不会自动转换数值。]]></description>
			<content:encoded><![CDATA[<p>PHP对于表单中提交的数据，因为默认为字符串的关系，所以不能使用is_int和is_float来验证来源数据是否正确。不过可以用一个折中的方法来验证，代码如下：</p>
<pre class="brush:php;">if((string)(int)$data===(string)$data)
    return true;
if((string)(float)$data===(string)$data)
    return true;</pre>
<p>原理是变为float或者int的字符串，前置0为自动清除。三个等号保证php不会自动转换数值。</p>
]]></content:encoded>
			<wfw:commentRss>http://klniu.com/post/php-int-float-check/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

