How call PHP native function in Model/Service/Controller scope I need to make a SoapClient new SoapClient call from within one of my Models for a validation rule. When I create the new SoapClient instance class in my Model function I'm getting this error message:

Fatal error: Class 'Craft\SoapClient' not found in...


I get the same error message whatever file Model/Service/Controller i put it in.

public function validateVatNumber()
{
    $client = new SoapClient("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl");
}


Could anyone let me know what I should do to be able to make these calls? I'm guessing I somehow need to "break free" from the Craft namespace.

Thank you
You need to backslash the class to tell it to look in the global namespace like so:

public function validateVatNumber()
{
    $client = new \SoapClient("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl");
}


You can read on the basics of PHP namespacing here: http://php.net/manual/en/language.namespaces.basics.php