yf_input class

Core input.

Fileplugins/sys/classes/yf_input.class.php
Use_class('input')

Public properties

PropertyDefaultDescription
None declared in this class.

Public methods 11

env

public function env($key = null, $val = null)

Helper to get/set ENV vars.

    public function env($key = null, $val = null)
    {
        if ($val !== null) {
            $_ENV[$key] = $val;
        }
        if (DEBUG_MODE && function_exists('debug')) {
            debug('input_' . __FUNCTION__ . '[]', [
                'name' => $key,
                'val' => $val,
                'op' => $val !== null ? 'set' : 'get',
                'trace' => main()->trace_string(),
            ]);
        }
        return $key === null ? $_ENV : ($_ENV[$key] ?? null);
    }

get

public function get($key = null, $val = null)

Helper to get/set GET vars.

    public function get($key = null, $val = null)
    {
        if ($val !== null) {
            $_GET[$key] = $val;
        }
        if (DEBUG_MODE && function_exists('debug')) {
            debug('input_' . __FUNCTION__ . '[]', [
                'name' => $key,
                'val' => $val,
                'op' => $val !== null ? 'set' : 'get',
                'trace' => main()->trace_string(),
            ]);
        }
        return $key === null ? $_GET : ($_GET[$key] ?? null);
    }

is_ajax

public function is_ajax()

Checks whether current page was requested with AJAX.

    public function is_ajax()
    {
        return (bool) main()->is_ajax();
    }

is_console

public function is_console()

Checks whether current page was requested from console.

    public function is_console()
    {
        return (bool) main()->is_console();
    }

is_post

public function is_post()

Checks whether current page was requested with POST method.

    public function is_post()
    {
        return (bool) main()->is_post();
    }

is_redirect

public function is_redirect()

Checks whether current page is a redirect.

    public function is_redirect()
    {
        return (bool) main()->is_redirect();
    }

post

public function post($key = null, $val = null)

Helper to get/set POST vars.

    public function post($key = null, $val = null)
    {
        if ($val !== null) {
            $_POST[$key] = $val;
        }
        if (DEBUG_MODE && function_exists('debug')) {
            debug('input_' . __FUNCTION__ . '[]', [
                'name' => $key,
                'val' => $val,
                'op' => $val !== null ? 'set' : 'get',
                'trace' => main()->trace_string(),
            ]);
        }
        return $key === null ? $_POST : ($_POST[$key] ?? null);
    }

server

public function server($key = null, $val = null)

Helper to get/set SERVER vars.

    public function server($key = null, $val = null)
    {
        if ($val !== null) {
            $_SERVER[$key] = $val;
        }
        if (DEBUG_MODE && function_exists('debug')) {
            debug('input_' . __FUNCTION__ . '[]', [
                'name' => $key,
                'val' => $val,
                'op' => $val !== null ? 'set' : 'get',
                'trace' => main()->trace_string(),
            ]);
        }
        return $key === null ? $_SERVER : ($_SERVER[$key] ?? null);
    }

session

public function session($key = null, $val = null)

Helper to get/set SESSION vars.

    public function session($key = null, $val = null)
    {
        if ($val !== null) {
            $_SESSION[$key] = $val;
        }
        if (DEBUG_MODE && function_exists('debug')) {
            debug('input_' . __FUNCTION__ . '[]', [
                'name' => $key,
                'val' => $val,
                'op' => $val !== null ? 'set' : 'get',
                'trace' => main()->trace_string(),
            ]);
        }
        return $key === null ? $_SESSION : ($_SESSION[$key] ?? null);
    }

Methods starting with _ hooks and helpers; not routable as page actions

__call

public function __call($name, $args)

Catch missing method call.

    public function __call($name, $args)
    {
        return main()->extend_call($this, $name, $args);
    }