This is a collection of questions that come up every now and then about syntax in PHP. This is also a Community Wiki, so everyone is invited to participate in maintaining this list.
It used to be hard to find questions about operators and other syntax tokens.¹
The main idea is to have links to existing questions on Stack Overflow, so it's easier for us to reference them, not to copy over content from …
跨越这行代码:
FormsAuth = formsAuth ?? new FormsAuthenticationWrapper();
Run Code Online (Sandbox Code Playgroud)
这两个问号意味着什么,是某种三元运算符?谷歌很难找到.
来自C#我必须用PHP做一个项目.
我正在使用此代码:
$transport = 'T';
$vehicle = (
( $transport == 'B' ) ? 'bus' :
( $transport == 'A' ) ? 'airplane' :
( $transport == 'T' ) ? 'train' :
( $transport == 'C' ) ? 'car' :
( $transport == 'H' ) ? 'horse' :
'feet' );
echo $vehicle;
Run Code Online (Sandbox Code Playgroud)
我希望它可以打印train,但我明白了horse.键盘示例:http://codepad.org/rWllfrht
谁能解释这种奇怪的行为?