Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8120725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:14:28+00:00 2026-06-06T05:14:28+00:00

Is there any special function to parse a .conf file in php like parse_ini_file()

  • 0

Is there any special function to parse a .conf file in php like parse_ini_file() function? If not how can I achieve that? Thanks!

EDIT :

Conf’s like httpd.conf(Apache). (I want to read and edit httpd.conf file)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T05:14:30+00:00Added an answer on June 6, 2026 at 5:14 am

    No, there is no special function to parse httpd.conf, but a parser should be easy to write. For example, if you’re only interested in the key-value settings, like ServerRoot /var/www, then this will do the trick:

    <?php
    
    define('HTTPD_CONF', '/tmp/httpd.conf');
    
    $lines = file(HTTPD_CONF);
    $config = array();
    
    foreach ($lines as $l) {
        preg_match("/^(?P<key>\w+)\s+(?P<value>.*)/", $l, $matches);
        if (isset($matches['key'])) {
            $config[$matches['key']] = $matches['value'];
        }
    }
    
    var_dump($config);
    

    If you want to parse the <Directory ...> and other blocks, it’ll take you a few more lines of code, but it shouldn’t be too taxing. It really depends on what you want to do. You can get a lot of info from $_SERVER and getenv(), so you might not need to parse a config file.

    EDIT

    In response to your update, for editing httpd.conf, you’ll need to run your script with superuser privileges and cause httpd.conf to be reloaded (e.g., system("apachectl graceful");).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to use any php function or whatever so that i can remove
I would like to know if there is any special way that one would
Hey, is there any built in functions or something like that in php that
Can anyone please tell me is there any special requirement to use either EXTERN
i want that during marshelling special character should escape, is there any way to
Are there any special considerations when Caching ASP.NET Pages on Azure? I understand that
I'd like to define a function which can show values of any type, with
Possible Duplicate: Is there any way to detect strings like putjbtghguhjjjanika? php check if
In php we can pass default arguments to a function like so function func_name(arg1,arg2=4,etc...)
Is there any way I can run class files (i.e. with main as the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.