php在调用中使用变量

时间:2019-10-22 17:45:35

标签: php api

  

致命错误:访问未声明的静态属性:   DTS \ eBaySDK \ Constants \ GlobalIds :: $已插入   /home/jimi13/public_html/dealpopup.com/ebayapi/finding/mine.php在   334行

$stripped = str_replace(' ', '', $country);
$stripped = preg_replace('/\s+/', '', $stripped);
echo $stripped;

需要将皮套剥掉

$service = new Services\FindingService([
    'credentials' => $config['production']['credentials'],
    'globalId'    => Constants\GlobalIds::US
]);

需要将其放入,但会引发错误

$service = new Services\FindingService([
    'credentials' => $config['production']['credentials'],
    'globalId'    => Constants\GlobalIds::$stripped
]);

1 个答案:

答案 0 :(得分:0)

这是一种可以使用名称空间访问类中的常量的方法。如果没有名称空间,则可以删除常量名称空间。

namespace Constants;

class Hello {
  const WORLD = 'Hello World';
}

$world = 'WORLD';
echo constant('Constants\Hello::' . $world);