Answer the question
In order to leave comments, you need to log in
Why doesn't php compile to javascript code?
The question is:
you need to get the IP of site visitors. JavaScript doesn't seem to have this option. But there is such an opportunity in PHP, IP users are recorded here: $_SERVER['REMOTE_ADDR']
I use NodeJS as a server.
In the index.html file, I inserted the script:
<script type="text/javascript">
var ip = "<?php echo $_SERVER['REMOTE_ADDR'] ?>";
alert("Твой IP "+ip);
alert(ip);
</script>
Answer the question
In order to leave comments, you need to log in
NodeJS
var ip = req.headers['x-forwarded-for'] ||
req.connection.remoteAddress ||
req.socket.remoteAddress ||
req.connection.socket.remoteAddress;
because you are trying to insert php code into the html document
I use NodeJS as a server.
In the index.html file, I inserted the script:
Because php interpreter is not working for you. Most likely, localhost is listening to node.js, not php.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question