简体   繁体   中英

Use of undefined constant PHP 7.2

Since updating, I'm occasionally seeing this warning

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

This is the line:

$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);

Just looking at it, should it be like

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

So just adding brackets around SSL_current? Was it always like this, because I never saw errors before.

I have looked at PHP's source and the constant SSL_CURRENT was never defined in any of the PHP version starting form version 4.

Therefore this issue is not related to the change of the PHP version.

For whatever reason you could not see warning about that constant before but it is for sure not PHP version update that made that constant undefined.

Since this string:

'SSL_CURRENT'

will always evaluate to true then this conditional expression:

'SSL_CURRENT' ? 's' : '';

is not conditional at all because it will always return "s":

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

so it can be also written this way

echo 's';

so it equals using it in your code this way:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM