Convert Javascript to PHP

1 posts Mon, Jan 30, 2023 at 10:19 AM in New Here & Getting Started

hello can anyone convert this js code to php??

<!DOCTYPE html>
<html lang="en">

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <div>Country: <span id="country"></span></div>
    <div>State: <span id="state"></span></div>
    <div>City: <span id="city"></span></div>
    <div>Postal: <span id="postal"></span></div>
    <div>Latitude: <span id="latitude"></span></div>
    <div>Longitude: <span id="longitude"></span></div>
    <div>IP address: <span id="ipv4"></span></div>

    let country = document.getElementById('country')
    let state = document.getElementById('state')
    let city = document.getElementById('city')
    let postal = document.getElementById('postal')
    let latitude = document.getElementById('latitude')
    let longitude = document.getElementById('longitude')
    let ip = document.getElementById('ipv4')

    function get(data) {
        country.innerHTML = data.country_name;
        state.innerHTML = data.state;
        city.innerHTML =;
        postal.innerHTML = data.postal;
        latitude.innerHTML = data.latitude;
        longitude.innerHTML = data.longitude;
        ip.innerHTML = data.IPv4;

    let script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = ''
    let r = document.getElementsByTagName('script')[0];
    r.parentNode.insertBefore(script, r)

View: Threaded  |  Flat
Sign In or Register to comment.