PHP:在页面中存储PHP变量以在POST中使用

Currently I put a constant on my webpage using PHP which I then send, with Ajax, to my POST function. However, this leaves it susceptible to hacking (the user could change the variable with Firebug), so is there a way to store the variable in the PHP of the page and then access it later on, in the POST method (or is the GET variable of the page still available in the POST function, since that's where I get the variable from)?

I think what you have wanted is to store the post value to use it later.

Here you would need to use $_SESSION

You can do it like

session_start();

// Save variables into session

$_SESSION['thevalue'] = $_POST['value'];

If you wish to store between successive calls from the same user use the follwing:

<?php
    session_start();
    $_SESSION["your variable/constant"] = yourvaule;

Now use the variable as needed, accessing it as $_SESSION["your variable/constant"]

Hope it helps, and it's what you're asking.