输入中出现意外字符:<b>/homepages/1/d835516322/htdocs/vitruvium/first.php</b> 中的 '\' (ASCII=92) state=1 <b>8</b><br />

问题描述

我有这个 PayPal 文档文件,我需要通过命令行运行它,一切看起来都很好,但我遇到了一些麻烦。 任何线索发生了什么以及如何解决它?我读了一些关于 windows 的 \r\n 并将其转换为 \n,但我不确定它是什么意思。

<?PHP

// 1. Autoload the SDK Package. This will include all the files and classes to your autoloader
require __DIR__  . '/PayPal-PHP-SDK/autoload.PHP';

// 2. Provide your Secret Key. Replace the given one with your app clientId,and Secret
// https://developer.paypal.com/webapps/developer/applications/myapps
$apiContext = new \PayPal\Rest\ApiContext(
    new \PayPal\Auth\OAuthTokenCredential(
        'my CLient id',// ClientID
        'My client secret'      // ClientSecret
    )
);

// 3. Lets try to create a Payment
// https://developer.paypal.com/docs/api/payments/#payment_create
$payer = new \PayPal\Api\Payer();
$payer->setPaymentMethod('paypal');

$amount = new \PayPal\Api\Amount();
$amount->setTotal('1.00');
$amount->setCurrency('USD');

$transaction = new \PayPal\Api\Transaction();
$transaction->setAmount($amount);

$redirectUrls = new \PayPal\Api\RedirectUrls();
$redirectUrls->setReturnUrl("https://neovinci.es/success.html")
    ->setCancelUrl("https://neovinci.es/cancel.html");

$payment = new \PayPal\Api\Payment();
$payment->setIntent('sale')
    ->setPayer($payer)
    ->setTransactions(array($transaction))
    ->setRedirectUrls($redirectUrls);

// 4. Make a Create Call and print the values
try {
    $payment->create($apiContext);
    echo $payment;

    echo "\n\nRedirect user to approval_url: " . $payment->getApprovalLink() . "\n";
}
catch (\PayPal\Exception\PayPalConnectionException $ex) {
    // This will print the detailed information on the exception.
    //REALLY HELPFUL FOR DEBUGGING
    echo $ex->getData();
}

但是当我从命令行运行它时总是出现这些错误

<b>Warning</b>:  Unexpected character in input:  '\' (ASCII=92) state=1 in <b>/homepages/1/d835516322/htdocs/vitruvium/first.PHP</b> on line <b>8</b><br />

<b>Parse error</b>:  Syntax error,unexpected T_STRING in <b>/homepages/1/d835516322/htdocs/vitruvium/first.PHP</b> on line <b>8</b><br />

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)