I have simple code that uses exec() to set a variable with some system information (like current IP.) I execute the code and display the information. I change the IP address of the computer and rerun the code. I'm using unset() to clear the variable before executing the code, however, it still displays the old information. How do I obtain the current information using exec()? Thanks in advance and sorry for the noob-iness.
<button type="button" class="btn btn-info btn-lg" onclick="showip()">Get IP</button>
<script>
function showip(){
<?php
unset($return);
unset($ip);
exec('wget https://ipinfo.io/ip -qO -', $return);
$ip = $return[0];
?>
curip = <?php echo(json_encode($ip, JSON_HEX_TAG)); ?>;
alert("The current IP is "+curip);
}
</script>