PHP basic syntax: ternary operator and other operators

Ternary operator and other operators

In addition, there are some special operators and symbols, which we will explain later. Maybe we need to use it later.

##$x? True code segment: Fake code Determine whether segment is true or false? True case: False case; `` (backticks) Insert command in the middle of backticks, Execute system commands, which is equivalent to the shell_exec function @ Suppress errors in a single line and prevent the errors in this line from being displayed. It is not recommended for low efficiency => Array subscript access code -> Object access code instanceof Determine whether an object comes from a certain class, if so return true, if not return false ##Ternary operator, equivalent to if...else structure. However, the ternary operator is more concisely written. The syntax format is as follows:
Symbol Description

$x? True code segment (only one line of code can be written): Fake code segment (only one line of code can be written) ;The code is as follows:

The backtick marks are even more special. We often need to display the IP address. Is it possible to display the IP address of our windows in PHP? Using backticks, you can execute our commands (but some virtual servers prohibit the execution of these command scripts):

'; echo `ipconfig`; echo '
'; ?>

Execute the above code to see the effect. Does it display the IP of your machine? Address and a bunch of IP-related parameters? The

@ symbol refers to single-line suppression of errors, which we will explain in future chapters. This is the understanding level.

The array subscript access operator will be explained in a chapter in the future. Just understand it here:

'新浪' ,'sohu' => '搜狐'); ?>

The object access operator -> and instanceof are both understanding levels. From now on There is also a special chapter to explain:

 username = 'PHP中文网'; echo $obj -> username; ?>

In all the above examples, except for the ternary operator, the @ symbol, and the backtick mark. All other learning levels are understanding and will be explained later. Just know that there is this symbol.

Continuing Learning
||
username = 'PHP中文网'; echo $obj -> username; ?>
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!