简体   繁体   中英

How to retrieve a variable from http.conf using PHP

How can one retrieve a varibale for instance alias /MyDirectory/ "C:/MyDirectory/MyDirectory/" from http.conf using PHP. Is there an easier way than to open http.conf and read it line by line?

Thanks

You could always use fgets() to read single lines from a file. But why would you want to tinker with your server settings from your program?

$handle = fopen('httpd.conf', 'r');
if($handle) {
    while($buffer = fgets($handle) !== false) {
        // do something with the data you read
    }
    if (!feof($handle)) {
        echo 'An error occured';
    }
    fclose($handle);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM