Application analysis of PHP short circuit operator

WBOY
Release: 2016-07-25 08:57:28
Original
981 people have browsed it
  1. /**
  2. * php short circuit operator
  3. * edit by bbs.it-home.org
  4. */
  5. mysql_query($sql) or die('Execute failed!');
  6. !file_exists($cache_file) && @update_cache($id);
  7. file_exists($cwd."/download/".$down_id)||mkdir($cwd."/download/".$down_id,0757)
  8. ?>
Copy code

Instructions: 1. [ or ][ || ][ and ][ && ] are short-circuit operators 2. The or, || operator will check whether the first expression returns "true". If it is "true", the end statement will return "true", otherwise the next expression will be checked. 3. The and, && operator checks whether the first expression returns "false". If it is "false", it ends the statement and returns "false". Otherwise, it checks the second expression.

The above uses the characteristics of short-circuit operators to realize the judgment and execution of conditions.



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template