文字

apache_note

(PHP 4, PHP 5, PHP 7)

apache_note取得或设置 apache 请求记录

说明

string apache_note ( string $note_name [, string $note_value = "" ] )

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

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

参数

note_name

note 名。

note_value

note 值。

返回值

如果只有一个参数调用,则返回记录 note_name 的当前值。如果用两个参数调用,则将记录 note_name 的值设为 note_value 并返回记录 note_name 的前一个值。如果未能获取记录,则返回 FALSE

范例

Example #1 Passing information between PHP and Perl

<?php

apache_note
( 'name' 'Fredrik Ekengren' );

// Call perl script
virtual ( "/perl/some_script.pl" );

$result  apache_note ( "resultdata" );
?>
# Get Apache request object
my $r = Apache->request()->main();# Get passed data
my $name = $r->notes('name');# some processing# Pass result back to PHP
$r->notes('resultdata', $result);

Example #2 Logging values in access.log

<?php

apache_note
( 'sessionID' session_id ());

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

参见

  • virtual() - 执行 Apache 子请求

用户评论:

[#1] ckm at NOSPAM dot crust dot net [2001-10-16 13:52:44]

apache_note() does not work on requests to a symlink, only on actual files.  Eg. if index.php is symlinked to login.php, then any apache_note() in login.php will not be available to other apache modules such as logging.

上一篇: 下一篇: