This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
PHP echo-ing content as page loads
I have a php page that has to load a heavy table, so after the page request there is a lot of time to wait.
Is it possible to send the page initially empty and, during the php page loading, send to the client the results, so one can see what has been loaded so far? (not a loading bar).
Yes. It's called flushing the document early. At its simplest, output some amount of HTML, and then calling flush();. As with most things, the devil is in the details of exactly what and when things would happen.
Related
This question already has answers here:
Loading content as the user scrolls down
(2 answers)
Closed 4 years ago.
Is it possible to get data from items that are loaded on scroll with simplehtml parser?
My code is done and it works perfectly I don't need any help with that , I'm just asking for advice if this is even possible to acomplish, I know when the dom praser loads what ever it sees on the first load of the page but is it possible to load more?
Example:
The page that i am loading has 10 items on it. But when you scroll down it Loads 10 more. Or thats not possible?
simple-html-dom doesn't do this by itself, you need to study how the javascript on the page fetches new items, and re-implement that in PHP. the "Network" tab of the Developer Tools of chrome is of great help in doing this, rather than study the javascript itself, you can just study the requests created by the javascript when you scroll, i usually find that to be a much easier approach.
This question already has answers here:
How to disable output buffering in PHP
(6 answers)
Closed 6 years ago.
I have programmed and set up a php web application on a shared Host (using apache server). Before the server being transferred, on each page, header and sidebar and ... was loaded and displayed and each part of the script was displayed immediately after being processed. For example if data was fetched from database and being displayed in a table, after displaying table header, each row was processed and displayed and then the next row and etc.
There has been a server transfer and apparently some configurations might have been changed and now each page is only displayed when the whole page is completely processed and is being displayed all at once.
I was wondering what the problem might be.
Thanks in advance
The issue here is Output Buffering. What happens with Output Buffering is, the output is not sent immediately, but gets sent only after the whole page is processed including delays and sleep.
You can disable output buffering to get the same experience. But beware, you will get the dreadly Headers already sent. errors sometimes.
See How to disable output buffering in PHP to disable output buffering per page or whole.
This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Closed 6 years ago.
Is there any way to prevent jQuery AJAX retreiving a complete PHP file instead of its server output ?
I just tried to obtain text only output, expecting what ever php decides to return, but got the whole file.
Not ideal if as on some files it would reveal potential hacking targets such as database tables etc
The host was not allowing config of private files, the solution was to move provider and place php above the root directory.
This question already has answers here:
how to make echo print out right away in PHP?
(4 answers)
Closed 9 years ago.
Is it possible to print out text in PHP while a for loop is running? I mean normally it runs the whole loop until the end and then you can see all the text. But I need the text every time when the echo is there in the for loop, not after the whole loop. Can someone give me an example?
void flush (void)
Flushes the write buffers of PHP and whatever backend PHP is using (CGI, a web server, etc). This attempts to push current output all the way to the browser with a few caveats. (more)
There are quite a few caveats. Make sure to read the linked page and comment section if you encounter any problems. For example:
Some versions of Microsoft Internet Explorer will only start to display the page after they have received 256 bytes of output, so you may need to send extra whitespace before flushing to get those browsers to display the page.
Keep in mind that Internet Explorer and Safari have a 1k buffer before incremental rendering kicks in, so you'll want to output some padding as well.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How do I render javascript from another site, inside a PHP application?
This is the site http://www.oferta.pl/strona_v2/gazeta_v2/ . This site is built totally on JavaScript. I want to scrape using PHP and curl. Currently I use DOMXPath. In the left menu there are some category to be selected. I see no 'form' there. How can I use curl to submit that form and scrap the output page?
I have used file_get_contents() only. It doesn't get all of the page. How can I proceed?
N.B : http://www.html-form-guide.com/php-form/php-form-submit.html I have found this example which have a 'form'. But my specified site has no 'form'.
You can not scrape it. Its possible. But its way too hard.
Simulate the http request by curl. Check every request it makes by ajax and try to simulate it.
Simulate Javascript executions (this part is almost impossible). Some requests contains values which are generated by Javascript. You need to do it in php. If they has some complicated algorithm implemented in JS you can invoke v8 javascript engine.