使用未定义常量 PHP 7.2

Use of undefined constant PHP 7.2

自更新以来,我偶尔会看到此警告

Warning: Use of undefined constant SSL_CURRENT - assumed 'SSL_CURRENT' (this will throw an Error in a future version of PHP) in /usr/www/domain/phpmyd/listing.php on line 151

这是行:

$pdf->Image($PMDR->get($PMDR->getConfig('map_type').'_Map')->getMapImageByCoords($listing['latitude'],$listing['longitude']),$pdf->GetX(),$pdf->GetY(),$pdf->pixelsToUnits(512),$pdf->pixelsToUnits(512),'','http'.(SSL_CURRENT ? 's' : '').'://maps.google.com/maps?q='.$listing['latitude'].','.$listing['longitude'],'N', false, 300);

随便看看,是不是应该像

$pdf->pixelsToUnits(512),'','http'.('SSL_CURRENT' ? 's' : '')

所以只是在 SSL_current 周围添加括号?是不是一直都是这样,因为我以前没见过错误。

我查看了 PHP 的源代码,常量 SSL_CURRENT 从未在任何从第 4 版开始的 PHP 版本中定义。

因此此问题与PHP版本的变化无关。

无论出于何种原因,您之前看不到关于该常量的警告,但肯定不是 PHP 版本更新导致该常量未定义。

因为这个字符串:

'SSL_CURRENT'

将始终评估为 true 那么这个条件表达式:

'SSL_CURRENT' ? 's' : '';

根本不是有条件的,因为它总是 return "s":

echo 'SSL_CURRENT' ? 's' : '';

所以也可以这样写

echo 's';

所以它等于在您的代码中以这种方式使用它:

$pdf->pixelsToUnits(512),'','https'