diff --git a/php/meterpreter/meterpreter.php b/php/meterpreter/meterpreter.php
index b772b3e9..200093af 100755
--- a/php/meterpreter/meterpreter.php
+++ b/php/meterpreter/meterpreter.php
@@ -445,7 +445,12 @@ function get_hdd_label() {
 
 function core_machine_id($req, &$pkt) {
   my_print("doing core_machine_id");
-  $machine_id = gethostname();
+  if (is_callable('gethostname')) {
+    # introduced in 5.3
+    $machine_id = gethostname();
+  } else {
+    $machine_id = php_uname('n');
+  }
   $serial = "";
 
   if (is_windows()) {