# SeasLog::setRequestVariable

(PECL seaslog >=1.9.0)

SeasLog::setRequestVariable — Manually set SeasLog request variable

### 说明

public static SeasLog::setRequestVariable(int `$key`, string `$value`): bool

Manually set SeasLog request variable.

### 参数

`key`

  Constant int.

  - SEASLOG_REQUEST_VARIABLE_DOMAIN_PORT
  - SEASLOG_REQUEST_VARIABLE_REQUEST_URI
  - SEASLOG_REQUEST_VARIABLE_REQUEST_METHOD
  - SEASLOG_REQUEST_VARIABLE_CLIENT_IP
`value`

  The request variable value.

### 返回值

Return TRUE on set success, FALSE on failure.

### 示例

示例 #1 SeasLog::setRequestVariable() example

`<?php
$sDomainPort = 'domain:port';
$sRequestUri = 'uri';
$sRequestMethod = 'method';
$sClientIp = 'client_ip';
$iErrorKey = 1000;
$oSeasLog = new SeasLog();
var_dump($oSeasLog->setRequestVariable(SEASLOG_REQUEST_VARIABLE_DOMAIN_PORT, $sDomainPort));
var_dump($oSeasLog->setRequestVariable(SEASLOG_REQUEST_VARIABLE_REQUEST_URI, $sRequestUri));
var_dump($oSeasLog->setRequestVariable(SEASLOG_REQUEST_VARIABLE_REQUEST_METHOD, $sRequestMethod));
var_dump($oSeasLog->setRequestVariable(SEASLOG_REQUEST_VARIABLE_CLIENT_IP, $sClientIp));
var_dump($oSeasLog->setRequestVariable($iErrorKey,NULL));
var_dump($oSeasLog->getRequestVariable(SEASLOG_REQUEST_VARIABLE_DOMAIN_PORT) == $sDomainPort);
var_dump($oSeasLog->getRequestVariable(SEASLOG_REQUEST_VARIABLE_REQUEST_URI) == $sRequestUri);
var_dump($oSeasLog->getRequestVariable(SEASLOG_REQUEST_VARIABLE_REQUEST_METHOD) == $sRequestMethod);
var_dump($oSeasLog->getRequestVariable(SEASLOG_REQUEST_VARIABLE_CLIENT_IP) == $sClientIp);
var_dump($oSeasLog->getRequestVariable($iErrorKey));
?>`

以上示例的输出类似于：

    bool(true)
    bool(true)
    bool(true)
    bool(true)
    bool(false)
    bool(true)
    bool(true)
    bool(true)
    bool(true)
    bool(false)

### 参见

- SeasLog::getRequestVariable() - Get SeasLog request variable

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open