Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP file will not update in browser

Tags:

browser

php

For some odd reason, every time I update a file, it is not updating inside a browser (localhost - wampserver). To be more specific. If I have a simple php script:

echo "hello world";

It runs fine in the browser, and shows the text 'hello world'.

However, if I update it to

echo "goodbye world";

And refresh the browser, nothing happens. The text remains 'hello world'.

This has not been a problem before and was refreshing perfectly. I tried clearing the browser cache, tested on multiple browsers, restarted my wamp server, and restarted the computer. Nothing seems to be working.

The only way the code seems to be updated is if I run the script from my IDE. Then it shows up in the browser with the updated code. How can this problem be fixed? I want it to go back to the way it was and be able to refresh from within the browser.

Using wampserver php - 5.3.13, apache 2.2.22

like image 290
Hyunmin Kim Avatar asked Jul 07 '12 06:07

Hyunmin Kim


People also ask

Why is PHP not working in browser?

So possible reasons could be: PHP is not installed properly on your system or the server is not properly installed. PHP module isn't loaded in your apache. You did not put your scripts in the right place.

Why is PHP file not working?

You have not setup the php interpreter correctly with your http server. If you are using apache2 .. then you need to setup PHP with apache. and uncomment LoadModel php5_module …. Originally Answered: Why won't my PHP code work?

Can Chrome run PHP files?

Conclusion. As you have learned, running a PHP file directly in the Chrome browser is not possible. However, there is great software such as XAMPP that will help you to run and test your php file.


2 Answers

Your script cached in memory with opcache feature. Disable it in php.ini:

opcache.enable = 0

But you also have to restart server. If you use hosting, use control panel to restart or try to change php version to another and revert.

like image 197
17 revs, 13 users 59% Avatar answered Nov 15 '22 20:11

17 revs, 13 users 59%


Since this is the first result on Google when searching for this kind of issue, I'd like to add that if you have opcache enabled, you don't necessarily need to disable it completely.

You probably have opcache.validate_timestamps set to 0 which will stop the automatic update of your files based on the last modification date.

Modify this parameter in your php.ini file:

opcache.validate_timestamps = 1

Restart the php-fpm service (or apache depending on your situation) and your script should be up to date at the next execution.

like image 22
thedotwriter Avatar answered Nov 15 '22 21:11

thedotwriter