Page 1 of 1
Can PHP modify a page after it has been served?
Posted: Wed Apr 13, 2011 1:47 pm
by Neville
I have never used PHP.
Can PHP modify a page after it has been served so that the modified page will be served next time?
Re: Can PHP modify a page after it has been served?
Posted: Thu Apr 21, 2011 3:01 am
by eivind
In combination with AJAX, you might.
http://w3schools.com/ajax/default.asp
Re: Can PHP modify a page after it has been served?
Posted: Thu Apr 21, 2011 11:05 am
by pickle
Not really.
When a URL is requested of PHP, PHP generates some output, passes that output to the web server, and the web server then returns that to the client. Often, before the page is even fully served up, PHP has finished executing. After that, there is no way to change what was sent to the client.
~elvind mentions AJAX, which allows you to use Javascript to dynamically load content into an existing webpage, without loading the webpage. That allows you to modify the page as it exists for the client, but it doesn't change the output a PHP file generates.
Re: Can PHP modify a page after it has been served?
Posted: Thu Apr 21, 2011 12:28 pm
by califdon
Tell us what you want to do and we can give you a better answer.
Re: Can PHP modify a page after it has been served?
Posted: Thu May 19, 2011 5:00 pm
by josh
Yes, the most simplistic example:
each time (or roughly each time) it will serve different content (random number). Guys I don't think hes talking about AJAX, the question implies a subsequent http request should serve new content. Yes this is possible, and is usually done.
Re: Can PHP modify a page after it has been served?
Posted: Thu May 19, 2011 9:44 pm
by califdon
Doesn't seem like this was really very important to him in the first place, anyway.