۲ Amir
پاسخ تمرین این جلسه
جامعه پی اچ پی ایجاد شده در ۰۶ خرداد ۱۴۰۲
class Request
{
    private $params;
    private $method;
    private $agent;
    private $ip;
    public function __construct()
    {
        $this->params = $_REQUEST; #params
        $this->agent = $_SERVER['HTTP_USER_AGENT'];
        $this->method = $_SERVER['REQUEST_METHOD'];
        $this->ip = $_SERVER['REMOTE_ADDR'];
    }
    public function params()
    {
        return $this->params;
    }
    public function method()
    {
        return $this->method;
    }
    public function agent()
    {
        return $this->agent;
    }
    public function ip()
    {
        return $this->ip;
    }
    public function input($key)
    {
        return $this->params[$key]??null;
    }
    public function isset($key)
    {
        return isset($this->params[$key]);
    }
    public function redirect($route)
    {
        header("Location: ".site_url($route));
        die();
    }
    public function __get(string $name):string|null {
        return array_key_exists($name, $this->params) ? $this->params[$name] : null;
    }
}

سلام امیر عزیز

این موارد رو در قالب نکته آموزشی باید ایجاد کنید.

احمدرضا فاطمی کیا ۰۷ خرداد ۱۴۰۲، ۱۵:۰۴

چشم ایشالا که قالب جدید رونمایی میشه تمرین‌ها هم اضافه شن این مشکلات پیش نیاد ?

Amir ۰۷ خرداد ۱۴۰۲، ۱۶:۱۴