PHP | ReflectionExtension export() Function

The ReflectionExtension::export() function is an inbuilt function in PHP which is used to return the export as a string if the return parameter is set to TRUE, otherwise NULL is returned.

Syntax:

string ReflectionExtension::export( string $name,
 string $return )

Parameters: This function accepts two parameters as mentioned above and described below:

  • $name: This parameter holds the export of reflection.
  • $return: This parameter holds the Boolean value. If its value is set to True then it will export the reflected extension. If its value is set to False then it will not export the reflected extension.

Return Value: This function returns the export as a string if the return parameter is set to TRUE, otherwise NULL is returned.

Below programs illustrate the ReflectionExtension::export() function in PHP:



Program_1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Defining an extension
$A = 'DOM';
  
// Using ReflectionExtension() over the 
// specified extension
$extension = new ReflectionExtension($A);
  
// Calling the export() function
$B = $extension->export($A, $return = FALSE);
  
// Getting the export as a string 
var_dump($B);
?>

chevron_right


Output:

Extension [ <persistent> extension #18 dom version 20031129 ] {

– Dependencies {
Dependency [ libxml (Required) ]
Dependency [ domxml (Conflicts) ]
}

– Constants [45] {
Constant [ integer XML_ELEMENT_NODE ] { 1 }
. . .
Constant [ integer DOM_VALIDATION_ERR ] { 16 }
}
. . .
. . .
– Parameters [3] {
Parameter #0 [ <required> $expr ]
Parameter #1 [ <optional> DOMNode or NULL $context ]
Parameter #2 [ <optional> $registerNodeNS ]
}
}

Method [ <internal:dom> public method registerPhpFunctions ] {

– Parameters [0] {
}
}
}
}
}
}

NULL



Program_2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Using ReflectionExtension() over 
// a extension xml
$extension = new ReflectionExtension('xml');
  
// Calling the export() function and
// Getting the export as a string 
var_dump($extension->export('xml', $return = TRUE));
?>

chevron_right


Output:

string(6209) “Extension [ <persistent> extension #15 xml version 7.0.33-0ubuntu0.16.04.7 ] {

– Dependencies {
Dependency [ libxml (Required) ]
}

. . .

Function [ <internal:xml> function utf8_decode ] {

– Parameters [1] {
Parameter #0 [ <required> $data ]
}
}
}
}

Reference: https://www.php.net/manual/en/reflectionextension.export.php




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.