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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:35:52+00:00 2026-05-26T14:35:52+00:00

using PHP Version 5.3.5 I am going insane. This piece of code is giving

  • 0

using PHP Version 5.3.5
I am going insane.
This piece of code is giving me hard time. After I refresh the page on Apache a few times, I get weird results. I think I have a memory leak here, but I can’t find out why.
Please help !

<?php 


function ost($active_sub_time,$arr_subscription_values)
{

    $result=0;

    while($active_sub_time>=12)
    {
        $active_sub_time-=12;
        $result+=($arr_subscription_values['COST_12']);
    }

    while($active_sub_time>=6)
    {
        $active_sub_time-=6;
        $result+=($arr_subscription_values['COST_6']);
    }
    while($active_sub_time>=3)
    {
        $active_sub_time-=3;
        $result+=($arr_subscription_values['COST_3']);
    }

    while($active_sub_time>=1)
    {
        $active_sub_time-=1;
        $result+=($arr_subscription_values['COST_1']);
    }

    if($active_sub_time>0)
        $result+=($active_sub_time)*($arr_subscription_values['COST_1']);

    if (!is_numeric($result))
    {
        echo"<br> Bug occurred";break; // print other values if necessary
    }

    return $result;
}

$datetime1 = date_create('2009-01-11');
$datetime2 = date_create('2001-11-09');
$interval = date_diff($datetime1, $datetime2);
$num_of_months = ($interval->y)*12 + ($interval->m) + ($interval->d)/(cal_days_in_month(CAL_GREGORIAN, $datetime2->format("m"), $datetime2->format("Y")));

$v = array('COST_1'=>'3.99','COST_3'=>'9.99','COST_6'=>'15.99','COST_12'=>'24.99');
echo "OPT value for $num_of_months months=".ost($num_of_months,$v);

?>

I do get this result at first:

OPT value for 86.066666666667 months=183.176

But after a few refreshes I get this :

OPT value for G.GMMMMMMMMMMMN months=183.176

Does anyone know why this is ?
Thanks

  • 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-26T14:35:52+00:00Added an answer on May 26, 2026 at 2:35 pm

    Cannot reproduce, I used your code exactly, and executed it multiple times. It displays the same result.

    There may be an issue with your server, or mashing refresh over and over is causing some kind of problem or memory limit.

    Check your php.ini and see if your memory limit is set too low, or max requests?

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

Sidebar

Related Questions

I'm using two different version of php on two different OS's. One is 5.2.9
We're using the Mantis bugtracker (version 1.1.8), which is based on PHP. To ease
I'm using XAMPP (latest version) on OS 10.6.2, that's bundled with PHP 5.3.0 I
Using PHP, what's the fastest way to convert a string like this: 123 to
I have been going through this tutorial on auto-populating boxes using jQuery and Ajax:
I need a PHP version of the following C# code: string dateSince = 2010-02-01;
This is my second attempt at a php contact form using Jquery and php
Using PHP and MySQL, I have a forum system I'm trying to build. What
Using PHP, I can convert MySQL data or static table data to csv, Excel,
Using PHP, I am trying to delete a record, but I want to check

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.