w3resource

PHP Declare Statement

Description

In PHP declare construct is used to set execution directives for a block of code. At present two directives are recognized ticks and encoding.

Syntax:

declare (directive) statement 

The following table describes two directives currently supported.

Directive Description
ticks A tick is an event. While the format of specifying the tick directive is tick=N, where N is an integer. The tick event occurs for every N statements (following the declare). Usually, condition expressions and argument expressions are excluded from being executed. Register_tick_function() is used to specify each event(s) that occur on each tick. Remember that this directive is deprecated in PHP5.3.
encoding The encoding directive specifies a script's encoding. Usage of this detective is decal re(encoding="EncodingType") where EncodingType is a encoding type like ISO-8859-1. This directive can be used only if PHP is compiled with --enable-zend-multibyte. You can use phpinfo() to know whether a PHP installation

Example of PHP declare statement using tick directive

<?php
declare(ticks=5);
// the following function is called on each tick event
function w3r_tick()
{
echo "w3r_tick() called<br>";
}
register_tick_function('w3r_tick');
$a = 5;
if ($a > 0)
{
$a += 2;
print($a);
}
?>

View the example in the browser

Previous: switch statement
Next: return statement



PHP: Tips of the Day

Convert HTML + CSS to PDF

Important: Please note that this answer was written in 2009 and it might not be the most cost-effective solution today in 2019. Online alternatives are better today at this than they were back then.

Here are some online services that you can use:

  • PDFShift
  • Restpack
  • PDF Layer
  • DocRaptor
  • HTMLPDFAPI
  • HTML to PDF Rocket

Have a look at PrinceXML.

It's definitely the best HTML/CSS to PDF converter out there, although it's not free (But hey, your programming might not be free either, so if it saves you 10 hours of work, you're home free (since youalso need to take into account that the alternative solutions will require you to setup a dedicated server with the right software).

Ref : https://bit.ly/384yytr