Check any content in php

I want to see if there are any POST settings. Anyway, can I do this?

+3
source share
3 answers
if (!empty($_POST)) {
    // handle post data
}
+8
source
if(count($_POST) > 0) {
    // Post vars are set
+3
source

Simple, $ _POST is an array containing all POST-vars, just count how all the elements are in the array, and you know if there is any set.

echo count($_POST);
0
source

Source: https://habr.com/ru/post/1727053/


All Articles