PHP API example issue

Im using the find mac-address example found on this page -
http://wiki.mikrotik.com/wiki/API_PHP_package

Only thing changed was the require_once line.

I receive this error when loading the page -

Parse error: parse error, expecting T_CONSTANT_ENCAPSED_STRING' or ‘(’’ in C:\Inetpub\wwwroot\mac.php on line 2

<?php use PEAR2\Net\RouterOS; require_once 'PEAR2_Net_RouterOS-1.0.0b4.phar'; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>

Your MAC address

<?php try { //Adjust RouterOS IP, username and password accordingly. $client = new RouterOS\Client('xxxx', 'admin', 'password');

$printRequest = new RouterOS\Request(‘/ip arp print .proplist=mac-address’);
$printRequest->setQuery(
RouterOS\Query::where(‘address’, $_SERVER[‘REMOTE_ADDR’])
);
$mac = $client->sendSync($printRequest)->getArgument(‘mac-address’);

if (null !== $mac) {
echo 'Your MAC address is: ', $mac;
} else {
echo ‘Your IP (’, $_SERVER[‘REMOTE_ADDR’],
“) is not part of our network, and because of that, we can’t determine your MAC address.”;
}
} catch(\Exception $e) {
echo “We’re sorry, but we can’t determine your MAC address right now.”;
}
?>

Anyone have an idea or a direction I should be looking?

You need to have PHP 5.3.0 or later for all examples (and the client in general) to work.

You’re most probably using 5.2.* or earlier. In it, there’s no namespaces (and by extension - the “use” keyword), and because of that, you have the parse error at line 2.

If you’re on a web hosting plan with cPanel, chances are you have a place from which you can change your PHP version. If not, contact your host about this or try a different one.

At the time I was on an older version but after upgrade was still having issues with namespaces.

I was able to get the miktoik4net client to work and that was my preferred choice as my app is written in .net anyways.

Thanks for the response, it is appreciated.