Knowing a server php extensions


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. /* set required extensions */
  3. $my_required_extensions = array(
  4. 'gd', //graphics library
  5. 'xml', //xml
  6. 'mysql', //database
  7. 'curl', //networking
  8. 'openssl', //site will need SSL
  9. 'pecl' //pear
  10. );
  11. natcasesort($my_required_extensions);
  12.  
  13. //get loaded modules
  14. $loaded_extensions = get_loaded_extensions();
  15. ?>
  16.  
  17. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  18. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  19. <head>
  20. <title><?php echo $source_article; ?> Example</title>
  21. <meta name="description" value="<?php echo htmlentities($meta_description); ?>" />
  22. <style type="text/css">
  23. body { font-size:12px; }
  24. h2 { border-bottom:1px solid #ccc; font-weight:normal; font-size:18px; margin-bottom:5px; padding-bottom:2px; }
  25. p { line-height:20px; margin-top:0; }
  26. .found { background:lightgreen; padding:5px 10px; margin:0 0 10px 0; }
  27. .miss { background:pink; padding:5px 10px; margin:0 0 10px 0; }
  28. .extra { background:lightblue; padding:5px 10px; margin:0 0 10px 0; }
  29. </style>
  30. </head>
  31. <body>
  32.  
  33. <h1><?php echo $_SERVER['HTTP_HOST']; ?></h1>
  34.  
  35. <h2>General Information</h2>
  36. <p>
  37. <strong>Server Software:</strong> <?php echo $_SERVER['SERVER_SOFTWARE']; ?><br />
  38. <strong>Document Root:</strong> <?php echo $_SERVER['DOCUMENT_ROOT']; ?><br />
  39. <strong>PHP Version:</strong> <?php echo phpversion(); ?>
  40. </p>
  41.  
  42. <h2>Extension Check</h2>
  43. <?php
  44. /* print out */
  45. //analyze results
  46. foreach($my_required_extensions as $ext)
  47. {
  48. if(in_array($ext,$loaded_extensions))
  49. {
  50. $matches[] = strtolower($ext);
  51. }
  52. else
  53. {
  54. $missings[] = strtolower($ext);
  55. }
  56. unset($loaded_extensions[$ext]);
  57. }
  58. //print out results
  59. natcasesort($matches); natcasesort($missings); natcasesort($loaded_extensions);
  60. foreach($matches as $match) { echo '<div class="found"><strong>',$match,'</strong> found!</div>'; }
  61. foreach($missings as $miss) { echo '<div class="miss"><strong>',$miss,'</strong> missing!</div>'; }
  62. foreach($loaded_extensions as $e) { if(!in_array($e,$matches) && !in_array($e,$missings)) { echo '<div class="extra"><strong>',$e,'</strong> is available.</div>'; } }
  63. ?><br />
  64.  
  65. </body>
  66. </html>

URL: http://blog.jeremymartin.name/2008/04/know-your-environment-php-server-module.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.