Home » Php » php – what is the usage of @ sign before $_SESSION

php – what is the usage of @ sign before $_SESSION

Posted by: admin February 25, 2020 Leave a comment

Questions:

In a php page I found the below code:

<form class="form-inline mr-auto" method="post">

    <div class="input-group">

        <input type="text" class="form-control" required placeholder="Search Proposals" name="search_query" value="<?php echo @$_SESSION["search_query"]; ?>">

        <span class="input-group-btn">
            <button class="btn btn-primary" name="search" type="submit">
                <i class="fa fa-search"></i>
            </button>
        </span>

    </div>

</form>

<?php

if(isset($_POST['search'])){

    $search_query = $_POST['search_query'];

    $_SESSION['search_query']=$search_query;

    header("location: $site_url/search.php");

}

?>

if you notice then inside the form for input type text there is a php code for value attribute where a session has been called.

 value="<?php echo @$_SESSION["search_query"]; ?>">

But what is the at sing @ used for before $_SESSION[“search_query”] ? is there any special meaning of at sign?

How to&Answers:

The @ sign suppresses errors in PHP.

https://www.php.net/manual/en/language.operators.errorcontrol.php