Pergunta

Hi guys I'm following this tutorial and I'm getting an extremely strange error message in my PHP when I try and run it in the web browser. The code is as follows:

    <?php
// Pull in the NuSOAP
require_once('nusoap.php');
// Create the server instance
$server = new soap_server();
// Initialize WSDL support
//(MyService is name of our service)
$server----->configureWSDL('MyService', 'urn:MyService');
        // Character encoding
        $server->soap_defencoding = 'utf-8';
        //-------------------------------------------------
        //Registrations of our functions
        //-------------------------------------------------
        //Our web service functions will be here.
        //-------------------------------------------------
        $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
        $server->service($HTTP_RAW_POST_DATA);
?>

Which is exactly as it's written in the tutorial, yet I keep getting this error message every time I run the PHP file:

UPDATE now I'm getting this error

Parse error: syntax error, unexpected T_DEC in /home/a1335235/public_html/MyService.php on line 8

Can anyone figure out why?

Foi útil?

Solução

As Mark Baker said in the comments (and I'll delete this if he posts first), your code is:

code require_once();

First and foremost code is not PHP. This should be require_once and you can see this in the PHP Manual. Secondly, require_once is a language construct. It's not a function call, so you don't need the (). You should have:

require_once 'nusoap.php';

The syntax error is telling you exactly what line the problem is on, so read it and google that bit of code to see how others are doing it and where you are going wrong in the future.

Now your issue is on line 8:

$server----->configureWSDL

This is not valid PHP either, unless you've heavily modifed the source code of the language, which you haven't. Change this to:

$server->configureWSDL()

That's how you call methods on objects. You should be reading the manual on Objects to see how this works.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top