JavaScript call PHP function same value alwalys

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


JavaScript call PHP function same value alwalys



I'm trying to call a php function, that run a shell command, inside my JavaScript on same page, it is supposed to return different value on each call but it call many times and use just the first return



PHP code:


<?php
$consulta = 'snmpget.exe -r:'.$ip.' -c:'.$dominio.' -o:'.$oid.'';

function exeSnmp ($consulta){
$arr = explode('Value=', shell_exec($consulta));
return preg_replace( "/r|n/", "", $arr[1] );
}
?>



And my JS code:


setInterval(function() {
var snmp = <?php echo json_encode(exeSnmp($consulta), JSON_HEX_TAG); ?>;
//doing something with snmp var
}, 1000);



When I run this code, I get always the same value from call exeSnmp() function, but its change on my system.



Thanks in advance.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results