|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69363 eval()ed string literal is not interned on PHP7+OPcache
Submitted: 2015-04-03 00:58 UTC Modified: 2015-04-03 03:32 UTC
From: for-bugs at hnw dot jp Assigned:
Status: Not a bug Package: opcache
PHP Version: master-Git-2015-04-03 (Git) OS: any
Private report: No CVE-ID: None
 [2015-04-03 00:58 UTC] for-bugs at hnw dot jp
On PHP7 without OPcache, eval('$bar="baz"') makes interned string. However, eval()ed string literal is dynamically allocated with OPcache enabled.

The interned string on PHP7 is not refcounted. So, string refcount(2) means non-interned.

Test script:

Expected result:
string(3) "baz" refcount(1)
string(3) "baz" refcount(1)

Actual result:
string(3) "baz" refcount(1)
string(3) "baz" refcount(2)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-03 02:39 UTC]
-Status: Open +Status: Not a bug
 [2015-04-03 02:39 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

first of all, use or not use interned string, should not be cared about user land, it's a internal optimization, and also affects by intend string memory pool size .

and for opcache, opcache won't do any optimization for EVAL_CODES. so...this behavior is expected.

 [2015-04-03 03:32 UTC] for-bugs at hnw dot jp
-Summary: eval()ed string literal is not intened on PHP7+OPcache +Summary: eval()ed string literal is not interned on PHP7+OPcache
 [2015-04-03 03:32 UTC] for-bugs at hnw dot jp
Hmm. If you are right, enabling OPcache on PHP 7 causes little bit performance loss  and consuming more memories when we use eval().

$ php7 -d 'opcache.enable_cli=Off' /tmp/test-script.php
string(3) "baz" refcount(1)
string(3) "baz" refcount(1)
$ php7 -d 'opcache.enable_cli=On' /tmp/test-script.php
string(3) "baz" refcount(1)
string(3) "baz" refcount(2)
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Nov 28 13:01:27 2023 UTC