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 ......
(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的算法都有哪些呢?
我还记得上大学那会学数据结构时,了解了:顺序法、冒泡法、二分法以及对线性表以及数据入栈、出栈的操作。
PHP中的顺序法就是对数组元素的逐一比较而得到的。
例如:
<?php
function order($php,$k)
{
$n = count($php); //计算数组个数
$php ......
一、session概述
session是什么,刚开始我也不明白,非专业词典翻译为会议,会议期。直到接触asp后才知道session是干什么的,有什么用。作个不太恰当的比喻吧(虽然不恰当,但意义却是一样的),session就好象你和你女友(或妻子)之间的感情似的,session是你和网站之间的感情。
se ......