I downloaded a PHP class (libphonenumber) from Github (https://github.com/davideme/libphonenumber-for-PHP)
It doesnt come with any docs or samples and I am having difficulty with it.
The only example I have gotten doesnt seem to work for me, I think its because of how I am trying to access it. but I am not sure how else to do it
The example I was given looks like this:
$exampleNumber = new PhoneNumber();
$exampleNumber->setCountryCode(1)->setNationalNumber(9311234567);
var_dump($this->phoneUtil->format($exampleNumber, PhoneNumberFormat::INTERNATIONAL));
var_dump($this->phoneUtil->format($exampleNumber, PhoneNumberFormat::NATIONAL));
var_dump($this->phoneUtil->format($exampleNumber, PhoneNumberFormat::RFC3966));
From what I have figured out, so far my code looks like this:
<?
namespace com\google\i18n\phonenumbers;
require_once dirname(__FILE__) . '/../PhoneNumberUtil.php';
require_once dirname(__FILE__) . '/../RegionCode.php';
require_once dirname(__FILE__) . '/../PhoneNumber.php';
require_once dirname(__FILE__) . '/../CountryCodeToRegionCodeMapForTesting.php';
$exampleNumber = new PhoneNumber();
$exampleNumber->setCountryCode(1)->setNationalNumber(9311234567);
var_dump($this->phoneUtil->format($exampleNumber, PhoneNumberFormat::INTERNATIONAL));
var_dump($this->phoneUtil->format($exampleNumber, PhoneNumberFormat::NATIONAL));
var_dump($this->phoneUtil->format($exampleNumber, PhoneNumberFormat::RFC3966));
?>
When I run this I get the error: "Fatal error: Using $this when not in object context in file.php on line 16"
I am not complrhending what my code needs to look like to access it from a flat file like this, I know $this isnt right, but I could very much use some help in understanding how I connect into this class.
Thanks for your help.