How can I execute $string = if();? [closed]

You have a few options to assign that value into $string but ill show two

First using regular if

$string = '';

if (!empty($_GET['category']) {
    $string = $_GET['category'];
}

Second using ternary operator

$string = !empty($_GET['category']) ? $_GET['category'] : '';

When working with data that you receive from outer sources, for example, inputs, url etc… its always best to validate and sanitize it.

For the sake of keeping this answer clean ill only include the function that is used for validation/sanitization of $_GET or $_POST filter_input

error code: 523