PHP 7 a me ka mea hana mokuna mokulele

Ma waho aʻe o nā hiʻohiʻona hou e like me ke ʻano hinting no nā ʻano ʻikepili scalar a i ʻole ka hoʻokō i hoʻomākaukau ʻia, lawe pū ʻo PHP 7 i nā mea hoʻolōʻihi ʻōlelo hou e pono ai. ʻO ka "Spaceship Operator" i hana hope ʻia i loko o ka honua o PHP (ua ʻike ʻo Ruby a me Perl programmer iā ia no kekahi manawa lōʻihi). \($a <=> $b\) hoʻihoʻi \(0\) inā a inā inā like nā hana ʻelua, \(1\) inā ʻoi aku ka nui o ka hema a me \(-1\) ʻē aʻe.


No laila, pili kēia mea hana hou i ka hana signum \(sgn(xy)\) ʻike ʻia mai ka makemakika. ʻO ka manaʻo o kēia hiki ke unuhi ʻia nā mea hoʻohana hoʻohālikelike e hoʻohana nei i ka syntax hou:

\($a < $b\)\(($a <=> $b) === -1\)
\($a <= $b\)\(($a <=> $b)\) !\(== 1\)
\($a == $b\)\(($a <=> $b) === 0\)
\($a\) !\(= $b\)\(($a <=> $b)\) !\(== 0\)
\($a >= $b\)\(($a <=> $b)\) !\(== -1\)
\($a > $b\)\(($a <=> $b) === 1\)

Pili nā lula like no nā mea hoʻohālikelike (e laʻa me \([1,2,3] <=>[1,2,1]\) like \(1\) ).

Hope