Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
207 views
in Technique[技术] by (71.8m points)

php 7 - PHP Invalid output of get_class_vars() after enabling (opcache.so) extension

I have this simple code that demonstrates updating a static value:

<?php

class myClass
{
    // empty static var
    public static $prop1;

}

myClass::$prop1 = array("Hey, I'm setting your value now");
var_dump(myClass::$prop1);

$allVars = get_class_vars( myClass::class ) ;
var_dump ( $allVars );

So I'm expecting both dumps to show the new value. While it works perfectly when (opcache) not enabled. But then it gives a bizarre output when (opcache) is enabled..

Is there any config responsible about this behavior ?

PHP 7.4.14

1-PHP 7.4.14 without opcache.so (OK)

array (size=1) 0 => string 'Hey, I'm setting your value now' (length=31)

array (size=1) 'prop1'

array (size=1)
  0 => string 'Hey, I'm setting your value now' (length=31)

2-PHP 7.4.14 with opcache.so enabled (Not ok, odd)

array(1) { [0]=> string(31) "Hey, I'm setting your value now" }
array(1) { ["prop1"]=> NULL }

What do you think ?

question from:https://stackoverflow.com/questions/65864824/php-invalid-output-of-get-class-vars-after-enabling-opcache-so-extension

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...