Question

I just upgraded to Ubuntu 14.04 and php5.5.9 and am having an issue with some old code.

This is probably something simple but is driving me crazy!

Boiled down, here is the issue:

  1. User submits a form
  2. POST values are used to generate a php file, with newly defined variables
  3. Directly below this in the code, the newly written file is included to recover the new variables - for testing purposes.
  4. But only the OLD variables are recovered.
  5. Refreshing the browser page gets the new variables.

I can't figure out why php is including the OLD file, not the newly written file.

Note: the file IS written correctly by php. But the OLD file is included, not the new one. If I hit browser refresh, the new values appear.

The variable file is written with php tags because I wrote it a long time ago. Not sure if I need to change it.

filename.php

<?php
$yesorno = "no";
?>

samplefile.php

include "/filepath/filename.php";

$opencar = '<';
$closecar = '>';
$fh = fopen("/filepath/filename.php", 'w') or die("can't open file");
fwrite($fh, $opencar."?php\n");
fwrite($fh, "\$yesorno = \"yes\";\n");
fwrite($fh, "?".$closecar."\n");
fclose($fh);

include "/filepath/filename.php";

echo "result: $yesorno";

execute samplefile.php

result: "no"

(refresh browser) result: "yes"

Looking at filename.php directly, it is immediately written correctly. Just not called correctly with the include.

What I've done:

php.ini:
allow_url_fopen = On 
allow_url_include = On  
restarted apache

tried various forms of clearstatcache This code works perfectly on older version of php.

Something obvious? Any help would be appreciated!

Was it helpful?

Solution

Do you have apc installed and enabled? If so, you'll have to clear its cache too. Call apc_clear_cache() or tell it to re-compile the updated file

apc_compile_file("/filepath/filename.php");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top