<?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>Fresker小站 &#187; PHP教程</title>
	<atom:link href="http://www.fresker.com/old2/archives/category/%e6%95%99%e7%a8%8b%e7%b1%bb/php%e6%95%99%e7%a8%8b/feed" rel="self" type="application/rss+xml" />
	<link>http://www.fresker.com/old2</link>
	<description>天将降大任于斯人也，必先苦其心志，劳其筋骨，饿其体肤，空乏其身....</description>
	<lastBuildDate>Sat, 05 May 2018 04:20:42 +0000</lastBuildDate>
	<language></language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>PHP5的异常处理机制（1）</title>
		<link>http://www.fresker.com/old2/archives/416</link>
		<comments>http://www.fresker.com/old2/archives/416#comments</comments>
		<pubDate>Wed, 07 Sep 2011 08:27:27 +0000</pubDate>
		<dc:creator>Duke</dc:creator>
				<category><![CDATA[PHP教程]]></category>
		<category><![CDATA[开发技术类]]></category>
		<category><![CDATA[教程类]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fresker.com/archives/416</guid>
		<description><![CDATA[PHP5的异常机制 PHP内建的异常类需要有以下成员方法： __construct() 构造函数，需要一个出错信息和一个可选的整型错误标记作参数 getMessage() 取得出错信息 getCode() 出错的代码 getFile() 异常发生的文件 getLine() 异常发生的行数 getTrace() 跟踪异常每一步传递的路线，存入数组，返回该数组 getTraceAsString() 和getTrace()功能一样，但可以将数组中的元素转成字符串并按一定格式输出 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; 可以看出来，Exception 类的结构和Pear_Error 很相似。当你的脚本中遇到一个错误，你可以建立你的异常对象： $ex = new Exception( "Could not open $this-&#62;file" ); Exception类的构造函数将接受一个出错信息和一个错误代码。 使用 throw关键字 建立一个Exception对象后你可以将对象返回，但不应该这样使用，更好的方法是用throw关键字来代替。throw用来抛出异常： throw new Exception( "my message", 44 ); throw 将脚本的执行中止，并使相关的Exception对象对客户代码可用。 以下是改进过的getCommandObject() 方法： index_php5.php [...]]]></description>
		<wfw:commentRss>http://www.fresker.com/old2/archives/416/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP5的异常处理机制（2）</title>
		<link>http://www.fresker.com/old2/archives/415</link>
		<comments>http://www.fresker.com/old2/archives/415#comments</comments>
		<pubDate>Wed, 07 Sep 2011 08:27:21 +0000</pubDate>
		<dc:creator>Duke</dc:creator>
				<category><![CDATA[PHP教程]]></category>
		<category><![CDATA[开发技术类]]></category>
		<category><![CDATA[教程类]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fresker.com/archives/415</guid>
		<description><![CDATA[Try-catch 语句 为了进一步处理异常，我们需要使用try-catch语句—包括Try语句和至少一个的catch语句。任何调用 可能抛出异常的方法的代码都应该使用try语句。Catch语句用来处理可能抛出的异常。以下显示了我们处理getCommandObject()抛出的异常的方法： index_php5.php 后半段 &#60;?php // PHP 5 try { &#160;&#160;&#160;&#160;$mgr = new CommandManager(); &#160;&#160;&#160;&#160;$cmd = $mgr-&#62;getCommandObject('realcommand'); &#160;&#160;&#160;&#160;$cmd-&#62;execute(); } catch (Exception $e) { &#160;&#160;&#160;&#160;print $e-&#62;getMessage(); &#160;&#160;&#160;&#160;exit(); } ?&#62; 可以看到，通过结合使用throw关键字和try-catch语句，我们可以避免错误标记“污染”类方法返回的值。因为“异常”本身就是一种与其它任何对象不同的PHP内建的类型，不会产生混淆。 如果抛出了一个异常，try语句中的脚本将会停止执行，然后马上转向执行catch语句中的脚本。 如果异常抛出了却没有被捕捉到，就会产生一个fatal error。 通过 Wiz 发布]]></description>
		<wfw:commentRss>http://www.fresker.com/old2/archives/415/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP5的异常处理机制（3）</title>
		<link>http://www.fresker.com/old2/archives/414</link>
		<comments>http://www.fresker.com/old2/archives/414#comments</comments>
		<pubDate>Wed, 07 Sep 2011 08:27:13 +0000</pubDate>
		<dc:creator>Duke</dc:creator>
				<category><![CDATA[PHP教程]]></category>
		<category><![CDATA[开发技术类]]></category>
		<category><![CDATA[教程类]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fresker.com/archives/414</guid>
		<description><![CDATA[处理多个错误 在目前为止异常处理看起来和我们传统的作法—检验返回的错误标识或对象的值没有什么太大区别。让我们将CommandManager处理地更谨慎，并在构造函数中检查command目录是否存在。 index_php5_2.php &#60;?php // PHP 5 require_once('cmd_php5/Command.php'); class CommandManager { &#160;&#160;&#160;&#160;private $cmdDir = "cmd_php5"; &#160;&#160;&#160;&#160;function __construct() { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (!is_dir($this-&#62;cmdDir)) { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;throw new Exception( &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;"directory error: $this-&#62;cmdDir"); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;function getCommandObject($cmd) { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$path = "{$this-&#62;cmdDir}/{$cmd}.php"; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (!file_exists($path)) { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;throw new Exception("Cannot find $path"); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;require_once $path; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (!class_exists($cmd)) { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;throw new Exception("class $cmd does not [...]]]></description>
		<wfw:commentRss>http://www.fresker.com/old2/archives/414/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP5的异常处理机制（4）</title>
		<link>http://www.fresker.com/old2/archives/413</link>
		<comments>http://www.fresker.com/old2/archives/413#comments</comments>
		<pubDate>Wed, 07 Sep 2011 08:27:08 +0000</pubDate>
		<dc:creator>Duke</dc:creator>
				<category><![CDATA[PHP教程]]></category>
		<category><![CDATA[开发技术类]]></category>
		<category><![CDATA[教程类]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fresker.com/archives/413</guid>
		<description><![CDATA[Exception类的子类 有两个理由让我们想要从Exception类中派生中子类： 1．&#160; 让子类提供自定义的功能； 2．&#160; 区分不同类型的异常； 看第二个例子。使用CommandManager类时我们可能会产生两个错误：一个是一般性的错误如找不到目录，另一个是找不到或无法生成Command对象。这样我们需要针对这两个错误来定义两种异常子类型。 index_php5_4.php &#60;?php // PHP 5 require_once('cmd_php5/Command.php'); class CommandManagerException extends Exception{} class IllegalCommandException extends Exception{} class CommandManager { &#160;&#160;&#160;&#160;private $cmdDir = "cmd_php5"; &#160;&#160;&#160;&#160;function __construct() { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (!is_dir($this-&#62;cmdDir)) { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;throw new CommandManagerException("directory error: $this-&#62;cmdDir"); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;function getCommandObject($cmd) { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$path = "{$this-&#62;cmdDir}/{$cmd}.php"; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (!file_exists($path)) { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;throw new IllegalCommandException("Cannot find $path"); [...]]]></description>
		<wfw:commentRss>http://www.fresker.com/old2/archives/413/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP5的异常处理机制（5）</title>
		<link>http://www.fresker.com/old2/archives/412</link>
		<comments>http://www.fresker.com/old2/archives/412#comments</comments>
		<pubDate>Wed, 07 Sep 2011 08:27:02 +0000</pubDate>
		<dc:creator>Duke</dc:creator>
				<category><![CDATA[PHP教程]]></category>
		<category><![CDATA[开发技术类]]></category>
		<category><![CDATA[教程类]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fresker.com/archives/412</guid>
		<description><![CDATA[如果我们已经触发了一些在发生时无法马上处理的异常，有一个很好的解决方案—将处理异常的责任交回给调用当前方法的代码，也就是在catch语句中再次抛出异常(重掷异常)。这将使异常沿着方法的调用链向上传递。 index_php5_5.php &#60;?php // PHP 5 class RequestHelper { &#160;&#160;&#160;&#160;private $request = array(); &#160;&#160;&#160;&#160;private $defaultcmd = 'defaultcmd'; &#160;&#160;&#160;&#160;private $cmdstr; &#160;&#160;&#160;&#160;function __construct($request_array=null) { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (!is_array($this-&#62;request = $request_array)) { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$this-&#62;request=$_REQUEST; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;function getCommandString() { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;return ($this-&#62;cmdstr ? $this-&#62;cmdstr : ($this-&#62;cmdstr=$this-&#62;request['cmd'])); &#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;function runCommand() { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$cmdstr = $this-&#62;getCommandString(); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;try { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$mgr = new CommandManager(); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$cmd = $mgr-&#62;getCommandObject($cmdstr); [...]]]></description>
		<wfw:commentRss>http://www.fresker.com/old2/archives/412/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP5的异常处理机制（6）</title>
		<link>http://www.fresker.com/old2/archives/411</link>
		<comments>http://www.fresker.com/old2/archives/411#comments</comments>
		<pubDate>Wed, 07 Sep 2011 08:26:55 +0000</pubDate>
		<dc:creator>Duke</dc:creator>
				<category><![CDATA[PHP教程]]></category>
		<category><![CDATA[开发技术类]]></category>
		<category><![CDATA[教程类]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fresker.com/archives/411</guid>
		<description><![CDATA[获得异常相关的更多信息 以下是用来格式化输出异常信息的代码： index_php5_6.php &#60;?php // PHP 5 class Front { &#160;&#160;&#160;&#160;static function main() { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;try { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$helper = new RequestHelper(array(cmd=&#62;'realcommand')); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$helper-&#62;runCommand(); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} catch (Exception $e) { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;print "&#60;h1&#62;".get_class($e)."&#60;/h1&#62;\n"; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;print "&#60;h2&#62;{$e-&#62;getMessage()} &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;({$e-&#62;getCode()})&#60;/h2&#62;\n\n"; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;print "file: {$e-&#62;getFile()}&#60;br /&#62;\n"; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;print "line: {$e-&#62;getLine()}&#60;br /&#62;\n"; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;print $e-&#62;getTraceAsString(); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;die; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;} } Front::main(); ?&#62; 如果你的realcommand类无法被实例化(例如你将它的构造函数声明为private)并运行以上代码，你可以得到这样的输出： ReflectionException Access to non-public constructor of class [...]]]></description>
		<wfw:commentRss>http://www.fresker.com/old2/archives/411/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php写数组信息到文件</title>
		<link>http://www.fresker.com/old2/archives/390</link>
		<comments>http://www.fresker.com/old2/archives/390#comments</comments>
		<pubDate>Fri, 08 Jul 2011 02:31:48 +0000</pubDate>
		<dc:creator>Duke</dc:creator>
				<category><![CDATA[PHP教程]]></category>
		<category><![CDATA[开发技术类]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fresker.com/archives/390</guid>
		<description><![CDATA[php写数组信息到文件，直接上代码，此处未判断文件是否存在，各位可以添加一个判断，此代码主要是使用var_export(); $test4mail = &#8220;test4mail.txt&#8221;; $file4mail = fopen($test4mail,&#8221;w&#8221;); fwrite($file4mail,var_export($new_mail_list,true)); fclose($file4mail); 通过 Wiz 发布]]></description>
		<wfw:commentRss>http://www.fresker.com/old2/archives/390/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>YII错误date()</title>
		<link>http://www.fresker.com/old2/archives/365</link>
		<comments>http://www.fresker.com/old2/archives/365#comments</comments>
		<pubDate>Mon, 23 May 2011 08:58:23 +0000</pubDate>
		<dc:creator>Duke</dc:creator>
				<category><![CDATA[Yii]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fresker.com/?p=365</guid>
		<description><![CDATA[有一段实际没有用yii啊， 记得当初用的时候还是1.1.4，现在都1.1.7了，今天架了一下，准备开始一个自己的项目，结果刚通过yiic　webapp webroot搞定了第一步，修改yii framework 位置之后，准备进入index看看效果，结果不是之前熟悉的首页，给了我一个页面 date(): It is not safe to rely on the system&#8217;s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected &#8216;UTC&#8217; for [...]]]></description>
		<wfw:commentRss>http://www.fresker.com/old2/archives/365/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHPer出路 phper成长过程</title>
		<link>http://www.fresker.com/old2/archives/331</link>
		<comments>http://www.fresker.com/old2/archives/331#comments</comments>
		<pubDate>Tue, 15 Mar 2011 16:54:01 +0000</pubDate>
		<dc:creator>Duke</dc:creator>
				<category><![CDATA[PHP教程]]></category>
		<category><![CDATA[开发技术类]]></category>
		<category><![CDATA[技术杂谈]]></category>
		<category><![CDATA[教程类]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fresker.com/?p=331</guid>
		<description><![CDATA[一张图片为自己做了不错的规划，php应该如何寻求自己的出路，如何找到发展的方向。下面的这张图能给自己一个引导作用。在此也与大家分享一下]]></description>
		<wfw:commentRss>http://www.fresker.com/old2/archives/331/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php获取文件后缀名</title>
		<link>http://www.fresker.com/old2/archives/314</link>
		<comments>http://www.fresker.com/old2/archives/314#comments</comments>
		<pubDate>Wed, 15 Dec 2010 03:14:50 +0000</pubDate>
		<dc:creator>Duke</dc:creator>
				<category><![CDATA[PHP教程]]></category>
		<category><![CDATA[开发技术类]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fresker.com/?p=314</guid>
		<description><![CDATA[1.$filename=$_FILES['userfile']['name']; //取得源文件的文件名 //如果需要演示一下可以将$filename直接赋值 $filename=&#8221;文件名 ./ ?$%@\#().doc&#8221;; //先取得后缀名 $pos=strrpos($filename,&#8221;.&#8221;); //取得文件名中后缀名的开始位置 $ext=substr($filename,$pos);//取得后缀名，包括点号 2.$upload_file_ext = strtolower(end(explode(&#8220;.&#8221;, $_FILES['upload_file']['name']))); 3.pathinfo($filename, PATHINFO_EXTENSION); eg:: &#60;?php $path_parts = pathinfo(&#8220;/www/htdocs/index.html&#8221;); echo $path_parts["dirname"] . &#8220;\n&#8221;; echo $path_parts["basename"] . &#8220;\n&#8221;; echo $path_parts["extension"] . &#8220;\n&#8221;; ?&#62; 上例将输出： /www/htdocs index.html html 4.mime_content_type(&#8220;文件名&#8221;)，绝对没有问题。 http://cn.php.net/manual/zh/function.mime-content-type.php Win32用户须将php安装目录下extensions下的php_mime_magic.dll文件copy到Windows系统目录下 (c:\windows or c:\winnt)，并修改php.ini文件，增加mime_magic.magicfile = &#8220;php安装目录\magic.mime&#8221;，将extension=php_mime_magic.dll一行前的注释去掉。 5.Linux下可以用 file 文件名]]></description>
		<wfw:commentRss>http://www.fresker.com/old2/archives/314/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->