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
相关文档:
最近的项目中使用到计划任务,通过bat执行php文件,然而发现php文件在浏览器中可以执行的很好,而bat调用却始终没有反应
autosave.bat中内容如下
D:\software\php\php.exe -q D:\web\works\mymedia\autosave.php
其中autosave.php文件中包含其他的类使用相对路径
直接在autosave.php里面输出echo 1;
可以在commond命令 ......
代码:
<?php
$im = imagecreatefromjpeg("ok.jpg");
$black = @imagecolorallocate($im, 0,0,0);
$jpgnumid = "这是嵌入到图片的文字,解决了乱码问题,
上面的ok.jpg是同目录下的照片.使用它时,还需要有iconv
模块!也就是说在php.ini里将
[iconv]
iconv.input_encoding = ISO-8859-1
iconv.internal_encodin ......
<?php
/*
* 分页实现
*/
include("conn.php");
$pagesize=2;
$url=$_SERVER["REQUEST_URI"];
$url=parse_url($url);
$url=$url[path];
$numq=mysql_query("SELECT * from test");
$num=mysql_num_rows($numq);
if($_GET[page]){
$pageval=$_ ......
级别: 中级
Jack D Herrington
(jherr@pobox.com
), 高级软件工程师, Leverage Software Inc.
2006 年 10 月 19 日
设计模式只是为 Java™ 架构师准备的 —— 至少您可能一直这样认为。实际上,设计模式对于每个人都非常有用。如果这些工具不是 “架构太空人” 的专利,那么它们又是什 ......
php中is_dir中能否正确返回确实和目录权限设置有关系。。。
弄了好久。。一直以为不是权限问题。
环境是iis6.0+php5.2
网站目录是在d:\vhost\web1
要用is_dir函数必须设置权限d:\,d:\vhost为可读可列目录
也就是web1前面几级的目录都要有可读可列目录的权限。 ......