apache_note

(PHP 4, PHP 5, PHP 7, PHP 8)

apache_note取得或设置 apache 请求记录

说明

apache_note(string $note_name, ?string $note_value = null): string|false

这个函数是 Apache table_gettable_set 的包装。 它编辑了请求中存在的 notes 表。 这个表的目的是允许 Apache 模块进行通讯。

apache_note() 的主要用途是在同一个请求中,从一个模块传递信息到另一个模块。

参数

note_name

note 名。

note_value

note 值。

返回值

如果 note_value 被省略或者为 null,则返回记录 note_name 的当前值。否则将记录 note_name 的值设为 note_value 并返回记录 note_name 的前一个值。如果未能获取记录,则返回 false

更新日志

版本 说明
8.0.0 现在 note_value 可为 null。

示例

示例 #1 在 PHP 与 Perl 之间传递信息

<?php

apache_note
('name', 'Fredrik Ekengren');

// 调用 perl 脚本
virtual("/perl/some_script.pl");

$result = apache_note("resultdata");
?>
# 获取 Apache 请求对象
my $r = Apache->request()->main();

# 获取传递的数据
my $name = $r->notes('name');

# 一些处理

# 将结果返回给 PHP
$r->notes('resultdata', $result);

示例 #2 在 access.log 中记录值

<?php

apache_note
('sessionID', session_id());

?>
# "%{sessionID}n" can be used in the LogFormat directive

参见

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top