Skip to content

Instantly share code, notes, and snippets.

@iledcom
Created August 21, 2015 08:14
Show Gist options
  • Save iledcom/03495a37002c6e869af5 to your computer and use it in GitHub Desktop.
Save iledcom/03495a37002c6e869af5 to your computer and use it in GitHub Desktop.
From JavaScript in PHP (method GET)
<script type="text/javascript">
var userName2 = 'Переменная';
</script>
<?php
if (isset($_GET['u_name']))
{
echo "Значение JavaScript-переменной: ". $_GET['u_name'];
}
else
{
echo '<script type="text/javascript">';
echo 'document.location.href="' . $_SERVER['REQUEST_URI'] . '?u_name=" + userName2';
echo '</script>';
exit();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment