当前位置: 首页>>代码示例>>PHP>>正文


PHP request::variable_names方法代码示例

本文整理汇总了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;
}
开发者ID:WarriorMachines,项目名称:warriormachines-phpbb,代码行数:40,代码来源:functions.php

示例2: test_variable_names

 public function test_variable_names()
 {
     $expected = array('test', 'unset');
     $result = $this->request->variable_names();
     $this->assertEquals($expected, $result);
 }
开发者ID:phpbb,项目名称:phpbb,代码行数:6,代码来源:request_test.php


注:本文中的phpbb\request\request::variable_names方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。