note 117727 added to function.opcache-reset

From: Date: Wed, 29 Jul 2015 17:08:05 +0000
Subject: note 117727 added to function.opcache-reset
Groups: php.notes 
Request: Send a blank email to php-notes+get-203213@lists.php.net to get a copy of this message
For people who have difficulties with constants and opcache_reset(). If you include a file with constant and do an opcache_reset() in the same file, you'll probably have some error like : "Notice: Constant already defined" The trick is to call opcache_reset() in an isolated file, then include another file that include the file with constants. File a.php <?php opcache_reset(); include 'b.php' ?> File b.php <?php include 'constants.php'; ?> File constants.php <?php define('MY_CONST', 'abcdef'); ?> With this trick, the opcache will be reset in a.php and when b.php will be included, the constants will not be in cache anymore. ---- Server IP: 72.52.91.14 Probable Submitter: 92.103.57.251 ---- Manual Page -- http://php.net/manual/en/function.opcache-reset.php Edit -- https://master.php.net/note/edit/117727 Del: integrated -- https://master.php.net/note/delete/117727/integrated Del: useless -- https://master.php.net/note/delete/117727/useless Del: bad code -- https://master.php.net/note/delete/117727/bad+code Del: spam -- https://master.php.net/note/delete/117727/spam Del: non-english -- https://master.php.net/note/delete/117727/non-english Del: in docs -- https://master.php.net/note/delete/117727/in+docs Del: other reasons-- https://master.php.net/note/delete/117727 Reject -- https://master.php.net/note/reject/117727 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#203213) next »