PHP $_GET and $_POST undefined problem

后端 未结 5 710
广开言路
广开言路 2020-12-06 14:22

I\'m new to PHP so I apologize if this is a simple problem...

I am moving a PHP site from one server to another. The new server is IIS 7.0, PHP 5.2.1, with short op

5条回答
  •  生来不讨喜
    2020-12-06 14:52

    isset() is a useful function. It returns "true" if the variable exists and "false" if not. Usually, people use it in conjunction with a superglobal like $_GET or $_POST to determine whether you're being sent from another page on the site - this allows you to create different actions based on where your user is coming from and what data is tagging along. It also prevents errors in trying to use variables you haven't yet defined, like the OP is getting. So instead of needing to write two different .php files and worrying about sending your user to the wrong one, you can do it all in one page.

    Jay, I'd be careful about your usage of some of these calls. is more likely to work than . I've heard session_start() should be the very first thing set to the browser or it can cause header issues. And yes, you need to have a variable declared before you use it - if you're not typing in [file].php?confirm=[some number] as your URL, your page will break unless you amend it to allow for breaks.

提交回复
热议问题