PHP declare control and ticks tutorials (with examples)

Source: Internet
Author: User

 declare is the process control structure of PHP, Directive currently supports two instructions, ticks use with the Register_tick_function function, see the following small example bar

The declare structure is used to set the execution instruction for a section of code, its syntax structure is as follows:   code is as follows: DECLARE (Directive) statement     don't understand? The popular explanation is as follows: Declare is the PHP Process Control structure, Directive currently supports two instruction "ticks and encoding", ticks use needs to match register_tick_function function (and of course unregister _tick_function function) is used. The ticks parameter represents a function that runs the number of statements called once register_tick_function. The Register_tick_function function defines the handler function at the time each tick event occurs. So what is the tick incident? Ick is an event. The Tick event occurs one time in PHP for each execution of n low-level statements, and n is specified by the Declare statement. You can use Register_tick_function () to specify the action that should be taken when the tick event occurs.   Problem again, what is the low-level statement? It includes: Simple statements: Empty statements (on A; number), return, break, continue, throw, Goto, Global, Static, unset, ECHO,   built-in HTML text, and the semicolon-terminated expression are counted as a single statement. Compound statement: The complete If/elseif, while, Do...while, for, foreach, switch, try...catch, etc. are counted as a statement. Statement BLOCK: A block of statements enclosed in {}. Finally Special: Declare block itself is also a statement (according to the reason declare block is also considered a compound statement, but here deliberately separate it out).   See a simple example: The   code is as follows: function Do_tick () {echo "<font color=red>do_tick</font>";} register_tick_fun Ction (' Do_tick ');   DECLARE (ticks = 1) {        for ($i = 1; $i < 5; $i + +)         {      &NBSP         echo "<font color=blue>{$i}</font><br>";        }}

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.