//klasa Request { $this->post = filter_input_array(INPUT_POST, $request, FILTER_SANITIZE_STRING); return $this->post; } //wywołanie metody: //print_r($_POST['product_check']); $postCheck = new Request(); $postCheck->sanitizePostArray('product_check')); }
No to skoro tablica oczekuje tablicy, a ja mu wrzucam tablicę $_POST['product_check'] to czego mi wali poniższym błędem?
Kod
Fatal error: Uncaught TypeError: nameOne\Request::sanitizePostArray(): Argument #1 ($request) must be of type array, string given, called in /home/xxx/public_html/index.php on line 20 and defined in /home/xxx/public_html/pagefiles/Request.php:24 Stack trace: #0 /home/xxx/public_html/index.php(20): nameOne\Request->sanitizePostArray('product_check') #1 {main} thrown in /home/xxx/public_html/pagefiles/Request.php on line 24
PS.
public function sanitizePostArray(array $request): array <---- Tutaj pierwsze array znaczy że wrzucamy tablicę do metody, a drugi array że metoda zwraca tablicę. Tak?