php - Embedding data into HTML page from shell_exec -


i new web development, , having small issue. creating html website on cluster administrate. have server uptime displayed on main page (index.html).

i have created php script (called test.php) following code:

<?php $uptime = shell_exec("cut -d. -f1 /proc/uptime"); $days = floor($uptime/60/60/24); $hours = $uptime/60/60%24; $mins = $uptime/60%60; $secs = $uptime%60; echo "up $days days $hours hours $mins minutes , $secs seconds"; ?> 

the code works fine on own when viewing test.php file, have can have same info on index.html page.

i cannot figure out how embed php file html file.

<iframe> tags considered bad practises, , should not adding <meta> tag in <body> either. unless have valid reasons, should avoid them.

the simplest solution use php instead of html index page.

however, if do need use html, fetch uptime php file via ajax , inject html file. here's example, using jquery:

$.ajax({     url: "test.php",     type: "get",     success: function(data) {         $(".uptime").html(data);     } }); 

again, not ideal solution, , should consider using php whole website instead.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -