PHP:沿标题位置传递消息

use*_*526 1 php

一旦用户输入了错误的数据,我想在页面上显示一条消息

到目前为止,我正在传递一条消息

    $Message = "Some error occured please try after some time ";
    header("Location:index.php?Message={$Message}");
Run Code Online (Sandbox Code Playgroud)

我知道这条消息只会显示在地址栏中,所以我应该怎么做才能让这条消息显示在index.php页面而不是

http://localhost/UI/index.php?Message=Someerror occured please try after some time
Run Code Online (Sandbox Code Playgroud)

Mih*_*rga 9

使用 urlencode()

$Message = urlencode("Some error occured please try after some time ");
header("Location:index.php?Message=".$Message);
die;
Run Code Online (Sandbox Code Playgroud)

并在index.php:

if(isset($_GET['Message'])){
    echo $_GET['Message'];
}
Run Code Online (Sandbox Code Playgroud)