<?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>Justin's Tech Blog &#187; ZEND API</title>
	<atom:link href="http://www.sofee.cn/blog/category/technical/php/zendapi/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sofee.cn/blog</link>
	<description>世界其实很简单，复杂的是人；生活其实很轻松，沉重的是感情！</description>
	<lastBuildDate>Sun, 17 Jan 2010 17:17:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP namespaces came back!</title>
		<link>http://www.sofee.cn/blog/2007/07/06/80/</link>
		<comments>http://www.sofee.cn/blog/2007/07/06/80/#comments</comments>
		<pubDate>Fri, 06 Jul 2007 02:50:56 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[ZEND API]]></category>
		<category><![CDATA[eAccelerator]]></category>
		<category><![CDATA[MMCache]]></category>
		<category><![CDATA[Namespace]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP5]]></category>
		<category><![CDATA[PHP6]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[ZEND-API]]></category>
		<category><![CDATA[Zend-Framework]]></category>
		<category><![CDATA[命名空间]]></category>

		<guid isPermaLink="false">http://www.sofee.cn/blog/2007/07/06/80/</guid>
		<description><![CDATA[近期PHP邮件列表最引人注目的应该就是namespace的开发了，Dmitry Stogov已经为PHP6打了个补丁，不过看上去已经很完美了。具体可以点这里看他发的帖子：Simple Namespace Proposal。
还记得以前PHP 5.0.0 alpha或beta的时候就已经支持namespace了，可后来推出正式版后却因为种种原因还是去掉了。现在想想namespace是越来越有用了，特别是针对Zend Framework这类框架的应用，颇有感触！希望经过这次的讨论之后会正式把这个功能加进来。

下面是相关代码的引用：

Namespaces are defined the following way:

Zend/DB/Connection.php: 
&#60;?php 
namespace Zend::DB;
&#160;
class Connection &#123;
&#125;
&#160;
function connect&#40;&#41; &#123;
&#125;
?&#62;

Namespace definition does the following:
All class and function names inside are automatically prefixed with
namespace name. Inside namespace, local name always takes precedence over
global name. It is possible to use the same namespace in several PHP files.
The namespace [...]]]></description>
		<wfw:commentRss>http://www.sofee.cn/blog/2007/07/06/80/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SMART STRING API</title>
		<link>http://www.sofee.cn/blog/2006/11/24/8/</link>
		<comments>http://www.sofee.cn/blog/2006/11/24/8/#comments</comments>
		<pubDate>Fri, 24 Nov 2006 04:41:20 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[ZEND API]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ZEND-API]]></category>

		<guid isPermaLink="false">http://www.sofee.cn/blog/?p=8</guid>
		<description><![CDATA[ 
var alimama_pid="mm_10006029_103557_106167"; 
var alimama_titlecolor="8ab459"; 
var alimama_descolor ="888888"; 
var alimama_bgcolor="FFFFFF"; 
var alimama_bordercolor="ffffff"; 
var alimama_linkcolor="8ab459"; 
var alimama_sizecode="12"; 
var alimama_width=468; 
var alimama_height=60; 
var alimama_type=2; 
 
 
 SMART STRING API
This article was copied from http://www.akbkhome.com/blog.php/View/111/smart_str_API.html
from:

#include &#34;ext/standard/php_smart_str.h&#34;

The Struct:

1
2
3
4
5
typedef struct &#123;
char *c;      // data goes here..
size_t len;     // the current [...]]]></description>
		<wfw:commentRss>http://www.sofee.cn/blog/2006/11/24/8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[老文章 ]使用VC++开发PHP扩展注意事项</title>
		<link>http://www.sofee.cn/blog/2006/06/26/20/</link>
		<comments>http://www.sofee.cn/blog/2006/06/26/20/#comments</comments>
		<pubDate>Mon, 26 Jun 2006 15:42:19 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[ZEND API]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP扩展]]></category>
		<category><![CDATA[VC++]]></category>
		<category><![CDATA[ZEND-API]]></category>

		<guid isPermaLink="false">http://www.sofee.cn/blog/?p=20</guid>
		<description><![CDATA[一、默认情况下，C++是使用.cpp作为扩展名的，而PHP是用C写的，因此必须使用C++提供的C连接交换指定符号extern &#8220;C&#8221;来解决这个问题，以下两部分语句必须被包含：

extern &#34;C&#34; &#123;
#include &#34;php.h&#34;
#include &#34;php_ini.h&#34;
#include &#34;ext/standard/info.h&#34;
... // 其他C头文件
&#125;

和

extern &#34;C&#34; &#123;
#ifdef COMPILE_DL_MYEXT
ZEND_GET_MODULE&#40;myext&#41;
#endif
&#125;


二、STL模版定义是不能被包含在C连接交换指定符的，而PHP需用到math.h这个头文件，因此编译的时候会产生math.h(514) error c2894: templates cannot be declared to have &#8216;C&#8217; linkage的错误信息，要解决这个问题，需在� 的CPP文件头部也就是extern &#8220;C&#8221;连接符之前加 入以下代码：

#ifdef WIN32
#include &#60;math.h&#62;
#endif

三、同C中一样，必须先在头文件（如：php_myext.h）中申明所有函数原型，如果没有使用头文件，那么必须在CPP文件（如：ext.cpp）的zend function结构之间申明所有函数原型，也就是在如下代码之前：

function_entry myext_functions&#91;&#93; = &#123;
PHP_FE&#40;confirm_myext_compiled, NULL&#41; /* For testing, remove later. */
&#123;NULL, NULL, NULL&#125;
&#125;;


  addthis_url    = 'http%3A%2F%2Fwww.sofee.cn%2Fblog%2F2006%2F06%2F26%2F20%2F';
  addthis_title  = '%5B%E8%80%81%E6%96%87%E7%AB%A0+%5D%E4%BD%BF%E7%94%A8VC%2B%2B%E5%BC%80%E5%8F%91PHP%E6%89%A9%E5%B1%95%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9';
  addthis_pub  [...]]]></description>
		<wfw:commentRss>http://www.sofee.cn/blog/2006/06/26/20/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[老文章]从PHP源代码修改phpinfo中的LOGO及彩蛋</title>
		<link>http://www.sofee.cn/blog/2006/06/26/19/</link>
		<comments>http://www.sofee.cn/blog/2006/06/26/19/#comments</comments>
		<pubDate>Mon, 26 Jun 2006 15:25:28 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[ZEND API]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP扩展]]></category>
		<category><![CDATA[ZEND-API]]></category>

		<guid isPermaLink="false">http://www.sofee.cn/blog/?p=19</guid>
		<description><![CDATA[1. 大家先来看一段PHP代码（gif2h.php）：

&#60;?php
// 将GIF转换为C语言中的H文件
$filename = &#34;mylogo.gif&#34;;
$fp = f open&#40;$filename, &#34;rb&#34;&#41;;
$buffer = f read&#40;$fp, filesize&#40;$filename&#41;&#41;;
f close&#40;$fp&#41;;
$len = strlen&#40;$buffer&#41;;
$fp = f open&#40;&#34;mylogo.h&#34;, &#34;wb&#34;&#41;;
f write&#40;$fp, &#34;unsigned char php_logo[] = {&#34;&#41;;
for &#40;$i=0; $i&#60;=$len; $i++&#41; &#123;
	if&#40;$i % 10 == 0&#41; &#123;
		f write&#40;$fp, &#34;\n\t\t&#34;&#41;;
	&#125;
	if&#40;$i == $len&#41; &#123;
		$str = str_pad&#40;ord&#40;substr&#40;$buffer, $i, 1&#41;&#41;, 3, &#34; &#34;, STR_PAD_LEFT&#41;;
	&#125; else &#123;
		$str = str_pad&#40;ord&#40;substr&#40;$buffer, $i, 1&#41;&#41;, 3, [...]]]></description>
		<wfw:commentRss>http://www.sofee.cn/blog/2006/06/26/19/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[老文章 ]PHP扩展中如何遍历数组？</title>
		<link>http://www.sofee.cn/blog/2006/06/26/17/</link>
		<comments>http://www.sofee.cn/blog/2006/06/26/17/#comments</comments>
		<pubDate>Mon, 26 Jun 2006 15:15:21 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[ZEND API]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP扩展]]></category>
		<category><![CDATA[ZEND-API]]></category>

		<guid isPermaLink="false">http://www.sofee.cn/blog/?p=17</guid>
		<description><![CDATA[
PHP_FUNCTION&#40;print_array&#41;
&#123;
	zval *z_array; // 外部引入的数组
	int count, i;
	zval **z_item;
	if &#40;FAILURE == zend_parse_parameters&#40;argc TSRMLS_CC, &#34;a&#34;, &#38;z_array&#41;&#41; &#123;
		return;
	&#125;
	// 获取数组大小
	count = zend_hash_num_elements&#40;Z_ARRVAL_P&#40;z_array&#41;&#41;;
	// 将数组的内部指针指向第一个单元
	zend_hash_internal_pointer_reset&#40;Z_ARRVAL_P&#40;z_array&#41;&#41;;
	for &#40;i = 0; i &#60; count; i++&#41; &#123;
		char* key;
		int idx;
		// 获取当前数据
		zend_hash_get_current_data&#40;Z_ARRVAL_P&#40;z_array&#41;, &#40;void**&#41; &#38;z_item&#41;;
		convert_to_string_ex&#40;z_item&#41;;
		if &#40;zend_hash_get_current_key&#40;Z_ARRVAL_P&#40;z_array&#41;, &#38;key, &#38;idx, 0&#41; == HASH_KEY_IS_STRING&#41; &#123;
			// KEY为字符串
			php_printf&#40;&#34;array[%s] = %s&#34;, key, Z_STRVAL_PP&#40;z_item&#41;&#41;;
		&#125; else &#123;
			// KEY为数字
			php_printf&#40;&#34;array[%d] = %s&#34;, idx, Z_STRVAL_PP&#40;z_item&#41;&#41;;
		&#125;
		// 将数组中的内部指针向前移动一位
		zend_hash_move_forward&#40;Z_ARRVAL_P&#40;z_array&#41;&#41;;
	&#125;
&#125;

在PHP调用如下：

&#60;?php
$arr = array&#40;
'id' =&#62; 'ezdevelop',
1 [...]]]></description>
		<wfw:commentRss>http://www.sofee.cn/blog/2006/06/26/17/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[老文章 ]quick lesson in using stream filters</title>
		<link>http://www.sofee.cn/blog/2006/06/26/16/</link>
		<comments>http://www.sofee.cn/blog/2006/06/26/16/#comments</comments>
		<pubDate>Mon, 26 Jun 2006 15:11:44 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[ZEND API]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP扩展]]></category>
		<category><![CDATA[stream]]></category>
		<category><![CDATA[ZEND-API]]></category>

		<guid isPermaLink="false">http://www.sofee.cn/blog/?p=16</guid>
		<description><![CDATA[Sara Golemon在新闻组发了一篇关于在PHP扩展中如何使用stream filters的文章 ，参考如下：
If all you want to do is use an already implemented one just do this:

php_stream *stream;
php_stream_filter *filter;
zval *arguments = NULL; /* Populate this with value(s) appropriate to the filter */
&#160;
stream = php_stream_open_wrapper&#40;.....blah blah blah.....&#41;;
filter = php_stream_filter_create&#40;&#34;filtername&#34;, arguments, php_stream_is_persistent&#40;stream&#41; TSRMLS_CC&#41;;
/* Or &#38;stream-&#62;writefilters as appropriate */
php_stream_filter_append&#40;&#38;stream-&#62;readfilters, filter&#41;;

/* Of course, in the real world you&#8217;ll [...]]]></description>
		<wfw:commentRss>http://www.sofee.cn/blog/2006/06/26/16/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
