无法加载PHP扩展

I'm using Apache2.4 with php7 on Windows 2008 server.

Some extensions are enabled in php.ini enter image description here

If you run php -m you can see they are installed

enter image description here

But when I put this code into a .php file under apache/htdocs and access it via localhost/aaa.php

<?php
print_r(get_loaded_extensions());
?>

Those enabled extensions are not shown, the output is

Array ( [0] => Core 
        [1] => bcmath 
        [2] => calendar 
        [3] => ctype 
        [4] => date 
        [5] => filter 
        [6] => hash 
        [7] => iconv 
        [8] => json 
        [9] => SPL 
        [10] => pcre 
        [11] => readline 
        [12] => Reflection 
        [13] => session 
        [14] => standard 
        [15] => mysqlnd 
        [16] => tokenizer 
        [17] => zip 
        [18] => zlib 
        [19] => libxml 
        [20] => dom 
        [21] => PDO 
        [22] => Phar 
        [23] => SimpleXML 
        [24] => xml 
        [25] => wddx 
        [26] => xmlreader 
        [27] => xmlwriter 
        [28] => apache2handler 
    )

If I put this into a.php and access it via localhost, I can also see GD is not installed.

<?php if ( extension_loaded( 'gd' ) ): ?>
                    <li class="success">GD extension loaded.</li>
<?php else: $success = FALSE; ?>
                    <li class="fail">You do not have the GD PHP extension loaded.</li>
<?php endif; ?>

However, if I run php.exe a.php, the result says GD is loaded.

So seems runing via the apache server and local php executable return different results. Can anyone help with this?