I have a PHP variable that I am trying to be able to update by means of a $_GET request, but the first time the page is loaded, it isn't updated. After the initial page load, if I reload the page again, it is updated. Why won't it work the first time?
PAGE.PHP:
$name = 'Bob';
include('start.php');
echo $name;
START.PHP:
if isset($_GET['name']) {
$name = $_GET['name'];
}
Example: page.php?name=Mary
Your start file has a syntax error, therefore the code never gets executed.
if (isset($_GET['name'])) {
^--------------------^--- missing
e.g.:
php > if isset($foo) { echo 'foo'; }
PHP Parse error: syntax error, unexpected 'isset' (T_ISSET), expecting '(' in php shell code on line 1
php > if (isset($foo)) { echo 'foo'; }
php >