How to determine the precedence level for PHP operators _php Tutorial

Source: Internet
Author: User
Tags constant definition php operator
When learning PHP, you may encounter the precedence of the PHP operator, here will explain the PHP operator priority problem resolution, here to share with you. PHP supports an error control operator: @. Any error messages that may be generated by the expression are ignored until it is placed in a PHP expression. If the track_errors attribute is activated, any error messages generated by the expression are stored in the variable $php_errormsg. This variable is overwritten every time an error occurs, so check it out as soon as possible if you want to use it.

 
  
  
  1. Php
  2. $ My_file = @file (' non_existent_file ') or
  3. Die ("Failedopeningfile:errorwas ' $php _errormsg '");
  4. $ value =@ $cache [$key];
  5. ?>

Note: The @ operator is only valid for an expression. A simple PHP operator precedence rule for beginners is that if you can get a value from somewhere, you can precede it with the @ operator. For example, you can put it in variables, functions and include () calls, constants, and so forth. It cannot be placed before the definition of a function or class, nor can it be used for conditional structures such as if and foreach. Execute operator: PHP supports an execution operator: an inverse quotation mark ('). Note that this is not a single quote! PHP will attempt to execute the contents of the anti-quote as a shell command and return its output information (for example, it can be assigned to a variable instead of simply discarding it to standard output). The effect of using the inverse quote operator "'" is the same as the function shell_exec ().

 
  
  
  1. Php
  2. $ Output = ' Ls-al ';
  3. echo " <pre> $output pre>";
  4. ?>

Note: The anti-quote operator is not valid when Safe mode is activated or shell_exec () is turned off.

Add one/minus one operator:
+ + $a the value of $ A before plus one, and then return $ A.
$a + + Returns a $ A and then adds a value of $ A.
--$a the value of $ A before minus one, then return $ A.
$a-minus a $ A, and then subtract a $ A value by one.

This is the C language of self-addition, self-reduction as a simple example to deepen the

 
 
  1. <html>
  2. <head>
  3. < title > PHP constant Definition--Tao essay title>
  4. head>
  5. <body>
  6. php
  7. $ a = 3 ;
  8. $ a =++ $a;
  9. echo$a. " <br> ";
  10. Output value is 4
  11. $ a = 3 ;
  12. $ a = $a + +;
  13. echo$a;
  14. Output value is 3
  15. ?>
  16. body>
  17. html>

http://www.bkjia.com/PHPjc/446482.html www.bkjia.com true http://www.bkjia.com/PHPjc/446482.html techarticle When learning PHP, you may encounter the precedence of the PHP operator, here will explain the PHP operator priority problem resolution, here to share with you. PHP supports a wrong ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.