Home > Uncategorized > Read Web.Config from PHP

Read Web.Config from PHP

Here is some code to read a setting from an ASP.NET web.config file using PHP

<?php
try
{
    function GetSetting($key)
    {
     $sxe = simplexml_load_file("C:Inetpubwwwrootweb.config");
     foreach($sxe->xpath(‘/configuration/appSettings/add’) as $item) {
        if ($item[‘key’] ==$key) return $item[‘value’];
     }
    }
    echo GetSetting(‘sqlclient’);
}
catch(Exception $e)
{
  echo ‘Message: ‘ .$e->getMessage();
}
?>

Advertisements
Categories: Uncategorized
  1. pramod
    December 23, 2010 at 7:54 am

    Hi,

    i m new in php so i have set up my site in codeignetor based on windows server. and also set .httaccess file for the removing index.php from url but unfortunetally it is not work for this.

    I have facing more issues on that problem so let me knowde about that how can i solve this issue. if u find any code please let me knowde.

    thanks

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: