易截截图软件、单文件、免安装、纯绿色、仅160KB

php扩展多进程共享内存

步骤:
1.运行命令:./ext_skel --extname=sharemem
2.运行命令:./configure --with-php-config=/usr/local/lnmp/php/bin/php-config
3.make clean
make
make install
/usr/local/lnmp/php/sbin/php-fpm restart
/usr/local/lnmp/php/bin/php-cgi /data0/htdocs/blog/sharemem.php
代码如下:
1.config.m4
PHP_ARG_ENABLE(sharemem, whether to enable sharemem support,
Make sure that the comment is aligned:
[  --enable-sharemem           Enable sharemem support])
if test "$PHP_SHAREMEM" != "no"; then
 
  PHP_NEW_EXTENSION(sharemem, sharemem.c, $ext_shared)
fi
2.php_sharemem.h
#ifndef PHP_SHAREMEM_H
#define PHP_SHAREMEM_H
extern zend_module_entry sharemem_module_entry;
#define phpext_sharemem_ptr &sharemem_module_entry
#ifdef PHP_WIN32
#define PHP_SHAREMEM_API __declspec(dllexport)
#else
#define PHP_SHAREMEM_API
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
/*hanhhh*/
#include "sys/mman.h"
#include "fcntl.h"
#include "semaphore.h"
#define FILE_MODE   (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
/*hanhhh*/
typedef struct php_shared_mm {
  sem_t mutex;  /* the mutex: a Posix memory-based semaphore */
  int count;  /* and the counter */
} php_shared_mm;
PHP_MINFO_FUNCTION(sharemem);
PHP_FUNCTION(say8_count_add); /* For testing, remove later. */
PHP_FUNCTION(say8_count_dec); /* For testing, remove later. */
#endif /* PHP_SHAREMEM_H */
3.sharemem.c
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_sharemem.h"
zend_function_entry sharemem_functions[] = {
 PHP_FE(say8_count_add, NULL)  
 PHP_FE(say8_count_dec, NULL)  
 {NULL, NULL, NULL} /* Must be the last line in sharemem_functions[] */
};
/* }}} */
/* {{{ sharemem_module_entry
 */
zend_module_entry sharemem_module_entry = {
#if


相关文档:

PHP 制作通讯录(四)

这次我们讲如何用PHP创建数据库以及表,和保存相关配置
先创建一个页面,用来输入相关信息
表单动作为 CreateData.php ,保存为Install.html (因为没有用到PHP,所以可以保存为HTML格式)
然后创建一个PHP文件,保存为CreateData.php ,用来创建数据库和保存相关信息
<?php
if(file_exists("Config.php"))
......

php 代替 echo 方法, 或者php的 替换语法使用方法.

修改php.ini文件.
如下.
1. short_open_tag = Off
如果改成On
我们可以在php中
<?= $variable?>来代替 <?php echo $variable ?>
2. asp_tags = Off
如果改成On
同样可以在php中
<%= $variable %> 来替代<?php echo $variable ?>
怎么样. 方便吧????
继续研究~~~~~~!!!!~~!~!~!~!~!~!~! ......

PHP文章如何和数据库连接(1)

(1)
Warning: mysql_query() [function.mysql-query]: Access denied for user
'ODBC'@'localhost' (using password: NO) in C:\Program Files\Apache
Software Foundation\Apache2.2\htdocs\TM\conn\conn.php on line 32
Warning: mysql_query() [function.mysql-query]: A link to the server could
not be est ......

五种常见的 PHP 设计模式


级别: 中级
Jack D Herrington
(jherr@pobox.com
), 高级软件工程师, Leverage Software Inc.
2006 年 10 月 19 日
设计模式只是为 Java™ 架构师准备的 —— 至少您可能一直这样认为。实际上,设计模式对于每个人都非常有用。如果这些工具不是 “架构太空人” 的专利,那么它们又是什 ......

利用php中的eval来模拟java中的动态代理

使用java中的动态代理可以完成很多事情,比如将业务实例进行托管,实现AOP等,但是Php中没有实现这样的东西,昨天突然想到其实可以通过eval来模拟一个动态代理机制。php比java不同的是,php是不需要编译的,因此只要我们能够动态生成一段代码,然后用eval来执行就可以达到效果。代码如下:
/**
* 代理实现类
*/
inter ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号