1

I have a php file, a.php, that includes b.php, that includes c.php.

So a.php looks like this:

<?php 
include_once('b.php'); 
// code
?>

and b.php looks like this:

<?php
include_once('c.php');
// code 
?>

When I run a.php I get this error:

Fatal error: Maximum execution time of 60 seconds exceeded in c.php

When I get this error I usually use:

ini_set('max_execution_time', 5000);

and the problem goes away.

I tried to put it in a.php and c.php but I still get the error.

First question is: Does it matter whether I put it in a.php or c.php? Second question: If setting max_execution_time in a.php and c.php does not work, what do I do?

Btw. I can't access php.ini so I can't just set it there. Note: Obviously this isn't my actual code and filenames, but this is pretty much the setup. I am using someone else's code. So b.php and c.php were created by someone else and I am creating a.php.

Andri
  • 453
  • 4
  • 22
  • Does c.php have `include_once('a.php');`? – Matt Apr 05 '17 at 20:24
  • Did you debug the execution for infinite loops or faulty recursive calls? Exceding maximum execution time is a symptom of a bad routine. – Youmy001 Apr 05 '17 at 20:54
  • 1
    `ini_set` must be placed at the earliest position in the execution (preferably at the top of the first script called) as it might not yet be executed when the error occurs. Per example, it could stop at 60 seconds before the maximum execution time gets extended. If extending the execution time does not work, you will have to optimize your code. – Youmy001 Apr 05 '17 at 20:56
  • @mkaatman No, there is no include_once('a.php'); in c.php – Andri Apr 05 '17 at 21:02
  • @Youmy001 There are no infinite loops in the code. Like I said, b.php and c.php were created by someone else (wsdltophp.com) and that code works well. The problem is that I am using a web service that gives me a lot of data (products, prices, etc.) and it takes time to loop through everything. The web service was probably made with companies that have a lot fewer products in mind, so I cannot limit the number of products. – Andri Apr 05 '17 at 21:06
  • @Youmy001 Or actually, I take that back. The problem is not the web service since I seem to be getting all the data before I get the error. The error comes when I am using some of that data to parse HTML, using https://github.com/ressio/pharse – Andri Apr 05 '17 at 21:18

0 Answers0