|
użytkowników online: 47
|
OPINIE UŻYTKOWNIKÓW
|
Przyznam, że jestem pod sporym wrażeniem. Od wielu lat zajmuje się grafiką przeznaczoną do druku ze szczególnym uwzględnieniem opakowań. Z radością stwierdzam, iż twórca serwisu jest moim ulubionym typem potencjalnego współpracownika (choć branża troszeczkę inna) tzn. pada pytanie i błyskawicznie pada konkretna odpowiedź bez względu na stopień skomplikowania pytania. Gorąco polecam współpracę, gdyż macie pewność że nie zostaniecie potraktowani sloganami typu "oczywiście", "nie ma sprawy" tylko otrzymacie konkretną pomoc. Tak trzymać! Na pewno jeszcze nie raz skorzystam
Paweł
Studio Gama
|
|
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net
[Spis]
[A]
[B]
[C]
[D]
[E]
[F]
[G]
[H]
[I]
[J]
[K]
[L]
[M]
[N]
[O]
[P]
[Q]
[R]
[S]
[T]
[U]
[V]
[X]
[W]
[Z]
XCI. Output Control Functions
The Output Control functions allow you to control when output is
sent from the script. This can be useful in several different
situations, especially if you need to send headers to the browser
after your script has began outputting data. The Output Control
functions do not affect headers sent using
header() or setcookie(),
only functions such as echo() and data between
blocks of PHP code.
Do zbudowania tego rozszerzenia nie są wymagane
żadne zewnętrzne biblioteki. By używać tych funkcji, nie trzeba niczego instalować.
Są one częścią jądra PHP.
Na działanie tych funcji wpływają ustawienia zawarte w pliku
php.ini.
Tabela 1. Output Control configuration options | Name | Default | Changeable | Changelog |
|---|
| output_buffering | "0" | PHP_INI_PERDIR | | | output_handler | NULL | PHP_INI_PERDIR | Available since PHP 4.0.4. | | implicit_flush | "0" | PHP_INI_ALL | PHP_INI_PERDIR in PHP <= 4.2.3. |
Szczegóły i definicje dotyczące stałych
PHP_INI_* znajdują się w rozdziale Dodatek H.
Oto krótkie wyjaśnienie dyrektyw
konfiguracji.
- output_buffering
boolean/integer
You can enable output buffering for all files by setting this directive
to 'On'. If you wish to limit the size of the buffer to a certain size -
you can use a maximum number of bytes instead of 'On', as a value for
this directive (e.g., output_buffering=4096).
As of PHP 4.3.5, this directive is always Off in PHP-CLI.
- output_handler
string
You can redirect all of the output of your scripts to a function. For
example, if you set output_handler to
mb_output_handler(), character encoding will be
transparently converted to the specified encoding. Setting any output
handler automatically turns on output buffering.
- implicit_flush
boolean
FALSE by default. Changing this to TRUE tells PHP to tell the
output layer to flush itself automatically after every output block.
This is equivalent to calling the PHP function
flush() after each and every call to
print() or echo() and each and
every HTML block.
When using PHP within an web environment, turning
this option on has serious performance implications and is generally
recommended for debugging purposes only. This value defaults to
TRUE when operating under the CLI SAPI.
See also ob_implicit_flush().
To rozszerzenie nie posiada żadnych rodzajów zasobów. To rozszerzenie nie posiada żadnych stałych.
Przykład 1. Output Control example |
<?php
ob_start();
echo "Hello\n";
setcookie("cookiename", "cookiedata");
ob_end_flush();
?>
|
|
In the above example, the output from echo()
would be stored in the output buffer until
ob_end_flush() was called. In the mean time,
the call to setcookie() successfully stored a
cookie without causing an error. (You can not normally send
headers to the browser after data has already been sent.)
Notatka:
When upgrading from PHP 4.1 (and 4.2) to 4.3 that due to a bug in
earlier versions you must ensure that
implict_flush is OFF in
your php.ini, otherwise any output with
ob_start() will not be hidden from output.
User Contributed NoteserwinX at darwineX dot nl
11-Nov-2005 02:35
[Concerns IE refusing to jump to a #something in the URL.]
I encoutered a bug in IE6/W2000 that can be solved by turning output buffering on.
Maybe it also helps in other situations/M$-OS, not sure.
Situation:
A page with a hash in the URL, and IE doesn't jump to that location.
Example:
http://www.bla.com/test.php#something
- In test.php the anchortag is placed normally like:
<a name="something"><br></a>
- test.php takes a few seconds to load because of heavy-duty database activity.
IE just ignores the hash #something.
It looks like IE 'forgets' the hash if it hasn't encoutered it YET in the HTML.
Turning output buffering on resolves that issue.
kend52 at verizon dot net
23-Jun-2005 08:25
I ran out of memory, while output buffering and drawing text on imported images. Only the top portion of the 5MP image was displayed by the browser. Try increasing the memory limit in either the php.ini file( memory_limit = 16M; ) or in the .htaccess file( php_value memory_limit "16M" ). Also see function memory_get_usage() .
gruik at libertysurf dot fr
10-Jul-2004 02:53
For those who are looking for optimization, try using buffered output.
I noticed that an output function call (i.e echo()) is somehow time expensive. When using buffered output, only one output function call is made and it seems to be much faster.
Try this :
<?php
your_benchmark_start_function();
for ($i = 0; $i < 5000; $i++)
echo str_repeat ("your string blablabla bla bla", (rand() % 4) + 1)."<br>\n";
echo your_benchmark_end_function();
?>
And then :
<?php
your_benchmark_start_function();
ob_start ();
for ($i = 0; $i < 5000; $i++)
echo str_repeat ("your string blablabla bla bla", (rand() % 4) + 1)."<br>\n";
echo your_benchmark_end_function();
ob_end_flush ();
?>
nobbie @t php d0t net
01-Apr-2004 02:49
There is a problem in MSIE 5.5,6 with regards to Page compression. Users might experience pages not loading completely, or just a blank page.
This articles you are looking for is what you're looking for:
Microsoft Knowledge Base Article - 312496 (for MSIE 6)
Microsoft Knowledge Base Article - 313712 (for MSIE 5.5)
It states that you should upgrade to the latest MSIE Service Pack to fix the following problem:
Internet Explorer May Lose the First 2,048 Bytes of Data That Are Sent Back from a Web Server That Uses HTTP Compression
tijmen
09-Jul-2003 01:44
Trying to benchmark your server when using output_buffering ?
Don't forget that the value 4096 in the php.ini will give you complete different loadtimes compares to the value of 1.
In the first case the output will be sent after buffering 4096 and the loadtime timed at the end of the page will contain the loadtime needed to download the complete page in the clientbrowser while the second value will contain the loadtime needed to place the complete page in the buffer. The time needed for sending is not clocked.
This can be very frustrating if you don't see the differance between server and the 1st is using 4096 instead of 1.
Although technically much faster than the second server the second server was providing much better loadtime results.
This result will grow when using large amounts of output.
But this becomes interesting if you want to measure the time needed for the page to be loaded for the client.
philip at thepr()jects dot ()rg
08-Feb-2001 08:17
|