本文整理汇总了PHP中phpbb\request\request::variable_names方法的典型用法代码示例。如果您正苦于以下问题:PHP request::variable_names方法的具体用法?PHP request::variable_names怎么用?PHP request::variable_names使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpbb\request\request
的用法示例。
在下文中一共展示了request::variable_names方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: phpbb_build_hidden_fields_for_query_params
/**
* Converts query string (GET) parameters in request into hidden fields.
*
* Useful for forwarding GET parameters when submitting forms with GET method.
*
* It is possible to omit some of the GET parameters, which is useful if
* they are specified in the form being submitted.
*
* sid is always omitted.
*
* @param \phpbb\request\request $request Request object
* @param array $exclude A list of variable names that should not be forwarded
* @return string HTML with hidden fields
*/
function phpbb_build_hidden_fields_for_query_params($request, $exclude = null)
{
$names = $request->variable_names(\phpbb\request\request_interface::GET);
$hidden = '';
foreach ($names as $name) {
// Sessions are dealt with elsewhere, omit sid always
if ($name == 'sid') {
continue;
}
// Omit any additional parameters requested
if (!empty($exclude) && in_array($name, $exclude)) {
continue;
}
$escaped_name = phpbb_quoteattr($name);
// Note: we might retrieve the variable from POST or cookies
// here. To avoid exposing cookies, skip variables that are
// overwritten somewhere other than GET entirely.
$value = $request->variable($name, '', true);
$get_value = $request->variable($name, '', true, \phpbb\request\request_interface::GET);
if ($value === $get_value) {
$escaped_value = phpbb_quoteattr($value);
$hidden .= "<input type='hidden' name={$escaped_name} value={$escaped_value} />";
}
}
return $hidden;
}
示例2: test_variable_names
public function test_variable_names()
{
$expected = array('test', 'unset');
$result = $this->request->variable_names();
$this->assertEquals($expected, $result);
}