When learning PHP, you may encounter a PHP operator priority problem. Here we will introduce the solution to the PHP operator priority problem. Here we will share it with you. PHP supports an error control operator :@. Before placing the expression in a PHP expression, any error information that may be generated by the expression is ignored. If the track_errors feature is activated, any error messages generated by the expression are stored in the variable $ php_errormsg. This variable will be overwritten every time an error occurs, so if you want to use it, you should check it as soon as possible.
- <?php
- $my_file=@file('non_existent_file')or
- die("Failedopeningfile:errorwas'$php_errormsg'");
- $value=@$cache[$key];
- ?>
Note: The @ operator is only valid for expressions. For beginners, a simple PHP operator priority rule is: if you can get a value from somewhere, you can add the @ operator before it. For example, you can place it before variables, functions, include () calls, constants, and so on. It cannot be placed before the definition of a function or class, nor can it be used for condition structures such as if and foreach. Execution OPERATOR: PHP supports an execution OPERATOR: backquotes (''). Note that this is not a single quotation mark! PHP will try to execute the content in the back quotes as a shell command and return its output information (for example, it can be assigned to a variable rather than simply discarded to the standard output ). The effect of using the unquoted operator "'" is the same as that of the shell_exec () function.
- <?php
- $output=`ls-al`;
- echo"<pre>$output</pre>";
- ?>
Note: The Ampersand operator is invalid when safe mode is activated or shell_exec () is disabled.
Plus or minus one operator:
+ + $ A add the value of $ a plus one, and then return $.
$ A ++ returns $ a after adding, and then adds the value of $.
-- Minus $ a before $ a minus one, and then returns $.
$ A -- returns $ a after subtraction, and then drops the value of $ a by one.
This is the same as the C language auto-increment and auto-subtraction. Let's take a simple example to learn more.
- <Html>
- <Head>
- <Title>Php constant definition -- A Tao's essay</Title>
- </Head>
- <Body>
-
- <?Php
-
- $A=3;
- $A= ++ $;
- Echo $ ."<Br>";
-
- // The output value is 4.
-
- $A=3;
- $A= $ A ++;
- Echo $;
-
- // The output value is 3.
-
- ?>
-
- </Body>
-
- </Html>