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 1029779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:35:53+00:00 2026-05-16T12:35:53+00:00

I am using the Zend Framework, and I use the .htaccess for some settings.

  • 0

I am using the Zend Framework, and I use the .htaccess for some settings. I am now writing command line scripts for scheduling (e.g. cron). Command line scripts don’t look at the .htaccess file because they’re not served up by Apache. I would like to parse the .htaccess with my script to retrieve some settings. Here are the lines I’m specifically interested in:

SetEnv APPLICATION_ENV development

php_value date.timezone America/New_York

I noticed the PEAR File_HtAccess package, but it seems to only address authentication portions of the .htaccess file.


SOLUTION: (with credit due to Bamieater)

echo statements for debug output, removed from working code.

$htaccess = file(realpath(dirname(__FILE__)) . '/.htaccess');
echo '<pre>';
foreach ($htaccess as $line) {
    if (preg_match('/^\s*SetEnv\s+APPLICATION_ENV\s+(.*?)\s*$/', trim($line), $matches)) {
        defined('APPLICATION_ENV') || define('APPLICATION_ENV', $matches[1]);
        echo APPLICATION_ENV . PHP_EOL;
    } elseif (preg_match('/^\s*php_(?:admin_)?value\s+date\.timezone\s+(.*?)\s*$/', $line, $matches)) {
        date_default_timezone_set($matches[1]);
        echo date_default_timezone_get() . PHP_EOL;
    }
}
echo '</pre>';
  • 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-05-16T12:35:54+00:00Added an answer on May 16, 2026 at 12:35 pm

    Read the .htaccess file per line and use a regular expression to access the data.

    For example something like this:

    $line = "php_value date.timezone America/New_York";
    $pattern = "@^php_value date.timezone (.*)$@";
    
    if(preg_match($pattern,$line,$matches))
    {
        print_r($matches);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been using Zend framework some time now, but I'm facing a problem I
I have been using Zend Framework for a while now. I am having an
I am using Zend Framework but not Zend_Application , just some classes - no
I am using Zend Framework(MVC part of it), and need to either redirect user
I am using the Zend Framework. I have a controller named 'UserController' that has
I have been using the Zend Framework with an MVC configuration, read about Ruby
This is my first experience using the Zend Framework. I am attempting to follow
I'm using Zend Studio to do remote debugging of my php scripts on a
I'm currently using Zend Framework in conjunction with PHPUnit to conduct unit testing on
I'm using Zend Studio 6.1 for Eclipse, which comes bundled with the Subversive plug-in.

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.