1--TEST-- 2Extension loading 3--SKIPIF-- 4<?php 5$extDir = ini_get('extension_dir'); 6if (!file_exists($extDir . '/opcache.so') && !file_exists($extDir . '/php_opcache.dll')) { 7 die('skip Opcache shared object not found in extension_dir'); 8} 9?> 10--FILE-- 11<?php 12 13 14function loadZendExt($extension) { 15 $cmd = [ 16 PHP_BINARY, '-n', 17 '-dextension_dir=' . ini_get('extension_dir'), 18 '-dzend_extension=' . $extension, 19 '-r', 'echo "Done.";' 20 ]; 21 $proc = proc_open($cmd, [['null'], ['pipe', 'w'], ['redirect', 1]], $pipes); 22 echo "Output: ", stream_get_contents($pipes[1]), "\n"; 23} 24 25echo "Only extension name:\n"; 26loadZendExt('opcache'); 27 28echo "Name with file extension:\n"; 29$name = PHP_OS_FAMILY == 'Windows' ? 'php_opcache.dll' : 'opcache.so'; 30loadZendExt($name); 31 32echo "Absolute path:\n"; 33$path = ini_get('extension_dir') . DIRECTORY_SEPARATOR . $name; 34loadZendExt($path); 35 36echo "Unknown extension name (unknown):\n"; 37loadZendExt('unknown_ext'); 38 39echo "Name with file extension (unknown):\n"; 40$name = PHP_OS_FAMILY == 'Windows' ? 'php_unknown_ext.dll' : 'unknown_ext.so'; 41loadZendExt($name); 42 43echo "Absolute path (unknown):\n"; 44$path = ini_get('extension_dir') . DIRECTORY_SEPARATOR . $name; 45loadZendExt($path); 46 47?> 48--EXPECTF-- 49Only extension name: 50Output: Done. 51Name with file extension: 52Output: Done. 53Absolute path: 54Output: Done. 55Unknown extension name (unknown): 56Output: 57Warning: Failed loading Zend extension 'unknown_ext' (tried: %s) in Unknown on line 0 58Done. 59Name with file extension (unknown): 60Output: 61Warning: Failed loading Zend extension '%Sunknown_ext%S' (tried: %s) in Unknown on line 0 62Done. 63Absolute path (unknown): 64Output: Failed loading %s 65Done. 66