Created
March 24, 2023 08:39
-
-
Save gnh1201/5e65db0ba7286fc06b3bc331ef08605b to your computer and use it in GitHub Desktop.
Extract all environment data from PHP runtime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Extract all environment data from PHP runtime | |
// Go Namhyeon <[email protected]> | |
echo "Extracting...<br/><br/>"; | |
$extracted_data = array(); | |
// Extracting all defined functions | |
echo "Extracting all defined functions...<br/><br/>"; | |
$my_functions = get_defined_functions(); | |
foreach($my_functions["internal"] as $name) { | |
$extracted_data[] = array( | |
'type' => 'function', | |
'scope' => 'global', | |
'value' => $name | |
); | |
} | |
// Extracting all defined constants | |
echo "Extracting all defined constants...<br/><br/>"; | |
$my_constants = get_defined_constants(true); | |
foreach($my_constants as $scope=>$functions) { | |
foreach($functions as $name=>$_) { | |
$extracted_data[] = array( | |
'type' => 'constant', | |
'scope' => $scope, | |
'value' => $name | |
); | |
} | |
} | |
// Extracting all defined classes | |
echo "Extracting all defined classes...<br/><br/>"; | |
$my_classes = get_declared_classes(); | |
foreach($my_classes as $name) { | |
$extracted_data[] = array( | |
'type' => 'class', | |
'scope' => 'global', | |
'value' => $name | |
); | |
} | |
// Extracting all loaded extensions | |
echo "Extracting all defined extensions...<br/><br/>"; | |
$my_extensions = get_loaded_extensions(); | |
foreach($my_extensions as $name) { | |
$extracted_data[] = array( | |
'type' => 'extension', | |
'scope' => 'global', | |
'value' => $name | |
); | |
} | |
echo "All done.<br/><br/>"; | |
// Show all extected data | |
echo "type,scope,value<br>"; | |
foreach($extracted_data as $item) { | |
echo implode(',', array($item['type'], $item['scope'], $item['value'])) . '<br/>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment