Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为什么
print "$str is " , ispalindrome($str) ? "" : " not" , " a palindrome\n"
打印“女士是回文”,但是
print "$str is " . ispalindrome($str) ? "" : " not" . " a palindrome\n"
印刷 ””?
条件运算符 ( ? :) 的优先级高于逗号,但低于句点。因此,第一行被解析为:
? :
print("$str is " , (ispalindrome($str) ? "" : " not"), " a palindrome\n")
而第二个被解析为:
print(("$str is " . ispalindrome($str)) ? "" : (" not" . " a palindrome\n"))