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
How to use zend library without using zend framework installation? I am trying to
I am using zend framework 1.10. I use the zf tool to create controllers,
I would like to use an IDE for PHP Development using Zend framework &
This article explains how to use Zend in Codeigniter. http://www.beyondcoding.com/2008/02/21/using-zend-framework-with-codeigniter/ I am using XAMPP
I'm currently using Zend Framework and for some of the actions in various controllers
In Zend Framework 1.8, using Zend_Tool, the framework now generates controllers, actions, etc. automatically.
I am using Zend Framework 1.9.6. I want to start using cron jobs. I
How do I import CSV files using zend framework? Should I use zend_file_transfer or
I'm using Zend_Validate to validate some form input (Zend Framework version is 1.8.2). For

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.