I honestly don't understand what you are trying to do, but in order to populate the variable, it needs to look like...
<a href="xxx.php" onclick="<?php $menus = "opened";?>">xxx</a>
instead of...
<a href="xxx.php" onclick="<?php $menus == "opened"?>">xxx</a>
Have you tried
<a href="xxx.php?menus=opened">xxx</a>