Sellingaccs is correct... Here's the code from mocacinno.com:
<?php
require_once('easybitcoin.php');
$bitcoin = new Bitcoin('[your rcp username here]','[your rcp password here]','[bitcoind\'s ip address here]','8332');
?>
bob123 is also correct, your server can't have a firewall that blocks port 8332, the port has to be correct,.... This is testable by opening a console and entering:
you can also try to open a telnet session from the host running the script to the host running the daemon (preferably the same host, since IIRC, json-rpc queries are sent in plain text)
oh, by the way, getinfo is depreciated.... i haven't updated my node yet, so i don't know if it's even still available...
{
"deprecation-warning": "WARNING: getinfo is deprecated and will be fully removed in 0.16. Projects should transition to using getblockchaininfo, getnetworkinfo, and getwalletinfo before upgrading to 0.16",
"version": 150100,
"protocolversion": 70015,
"walletversion": 60000,
"balance": 0.00000000,
"blocks": 518594,
"timeoffset": 0,
"connections": 30,
"proxy": "",
"difficulty": 3839316899029.672,
"testnet": false,
"keypoololdest": 1479499499,
"keypoolsize": 1000,
"paytxfee": 0.00000000,
"relayfee": 0.00001000,
"errors": ""
}