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命令 ......
<?
error_reporting(2047);#报告所有非法的错误
ob_start();
function RMB ($RMB=0,$Format='') {
/*
*/
$RMB=@preg_Replace(
array('/([, ]|¥|0$|)/','/(.){2,}/'),
array('','.'),
$RMB);
if(eregi("[^0-9.]",$RMB))return "非法金额";
if($RMB==0)retur ......
<?php
$zip_filename = "testpm.zip";
$zip_filename = key_exists('zip', $_GET) && $_GET['zip']?$_GET['zip']:$zip_filename;
$zip_filepath = str_replace('\\', '/', dirname(__FILE__)) . '/' . $zip_filename;
if(!is_file($zip_filepath))
{
die('文件"'.$zip_ ......
最近在折腾 PHP + MYSQL
的编程。了解了一些 PHP SQL 注入攻击
的知识,于是写了这篇文章 http://www.xiaohui.com/weekly/20070314.htm,总结一下经验。在我看来,引发 SQL 注入攻击
的主要原因,是因为以下两点原因:
1. php 配置文件 php.ini 中的 magic_quotes_gpc
选项没有打开,被置为 off
2. 开发 ......