note 126614 added to control-structures.declare

From: Date: Mon, 15 Nov 2021 17:00:59 +0000
Subject: note 126614 added to control-structures.declare
Groups: php.notes 
Request: Send a blank email to php-notes+get-217251@lists.php.net to get a copy of this message
While you cannot conditionally declare ticks in a single source file, as the declare() is processed even within the branch of an if() that does not run, you can work around this by placing it within a separate file, and conditionally including that file, like so: <?php if (function_exists('pcntl_async_signals')) { pcntl_async_signals(true); } else { require_once('declareTicks.php'); } ?> Then in declareTicks.php you'd have just: <?php declare(ticks=1); ?> This allows you to avoid the performance impact of a low tick value in systems which support pcntl_async_signals(). ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 65.36.66.178) ---- Manual Page -- https://php.net/manual/en/control-structures.declare.php Edit -- https://main.php.net/note/edit/126614 Del: integrated -- https://main.php.net/note/delete/126614/integrated Del: useless -- https://main.php.net/note/delete/126614/useless Del: bad code -- https://main.php.net/note/delete/126614/bad+code Del: spam -- https://main.php.net/note/delete/126614/spam Del: non-english -- https://main.php.net/note/delete/126614/non-english Del: in docs -- https://main.php.net/note/delete/126614/in+docs Del: other reasons-- https://main.php.net/note/delete/126614 Reject -- https://main.php.net/note/reject/126614 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#217251) next »