i have this code in the top of my index.php. And it works perfect when i run it locally with mamp. But when i go live with the page and upload it to the hosting service and launch the website i get this error in the log. And the site does not load.
PHP Parse error: syntax error, unexpected '?' in /home/*****/*****.*****.**/index.php on line 3
<?php
session_start();
$AccountsucessRegister = $_SESSION['Accountsucess'] ?? '';
$AccountfailRegister = $_SESSION['Accountfail'] ?? '';
unset($_SESSION['Accountsucess']);
unset($_SESSION['Accountfail']);
?>
<?php if ($AccountsucessRegister !== ''): ?>
<?php echo "<script>alert('$AccountsucessRegister');</script>" ?>
<?php endif; ?>
<?php if ($AccountfailRegister !== ''): ?>
<?php echo "<script>alert('$AccountfailRegister');</script>" ?>
<?php endif; ?>
Maybe you have on local php7+ version and at your provider not.
Among provider have .ini file option to change the php version on shared hosting but if not the error comes from
$AccountsucessRegister = $_SESSION['Accountsucess'] ?? '';
must be
$AccountsucessRegister = isset($_SESSION['Accountsucess']) ? $_SESSION['Accountsucess'] : '';