Esercitazione PHP

PHP HOME Introduzione a PHP Installazione PHP Sintassi PHP Commenti PHP Variabili PHP PHP Eco/Stampa Tipi di dati PHP Stringhe PHP Numeri PHP PHP matematica Costanti PHP Operatori PHP PHP Se...Altro...Altro Passaggio PHP Ciclo PHP Funzioni PHP Array PHP Superglobali PHP RegEx PHP

Moduli PHP

Gestione dei moduli PHP Convalida del modulo PHP Modulo PHP richiesto URL/e-mail del modulo PHP Modulo PHP completo

PHP avanzato

Data e ora PHP PHP Include Gestione dei file PHP Apri/Leggi file PHP Creazione/scrittura di file PHP Caricamento file PHP Cookie PHP Sessioni PHP Filtri PHP Filtri PHP avanzati Funzioni di callback PHP PHP JSON Eccezioni PHP

PHP OOP

PHP Che cos'è OOP Classi/Oggetti PHP Costruttore PHP PHP distruttore Modificatori di accesso PHP Ereditarietà PHP Costanti PHP Classi astratte PHP Interfacce PHP Tratti PHP Metodi statici PHP Proprietà statiche PHP Spazi dei nomi PHP Iterabili PHP

Database MySQL

Database MySQL MySQL Connect MySQL Crea DB MySQL Crea tabella Dati di inserimento MySQL MySQL Ottieni l'ultimo ID MySQL inserisce più MySQL preparato MySQL Seleziona dati MySQL dove MySQL Ordina per MySQL Elimina dati Dati di aggiornamento MySQL Dati limite MySQL

PHP XML

Parser XML PHP Analizzatore PHP SimpleXML PHP SimpleXML - Ottieni PHP XML espatriato PHP XML DOM

PHP - AJAX

Introduzione all'Ajax AJAX PHP Database AJAX XML AJAX Ricerca in tempo reale AJAX Sondaggio AJAX

Esempi PHP

Esempi PHP compilatore PHP Quiz PHP Esercizi PHP Certificato PHP

Riferimento PHP

Panoramica di PHP matrice PHP Calendario PHP Data PHP Directory PHP Errore PHP Eccezione PHP File system PHP Filtro PHP PHP FTP PHP JSON Parole chiave PHP PHP Libxml Posta PHP PHP matematica PHP Varie PHP MySQLi Rete PHP Controllo dell'output PHP RegEx PHP PHP SimpleXML Flusso PHP Stringa PHP Gestione delle variabili PHP Analizzatore XML PHP Zip PHP Fuso orario PHP

Funzioni di controllo dell'output PHP


Funzioni di controllo dell'output PHP

PHP fornisce una serie di funzioni che controllano quale contenuto viene inviato al browser e quando. Questo è indicato come controllo dell'uscita .

L'output può provenire da una delle seguenti fonti:

  • echo, print, printf, print_r... e altre funzioni e istruzioni simili
  • Avvisi, avvisi ed errori da PHP
  • Qualsiasi contenuto al di fuori dei <?php ?>tag

PHP e il backend su cui è in esecuzione possono contenere l'output in un buffer prima di inviarlo all'utente.

Nota: le funzioni di controllo dell'uscita possono creare un numero qualsiasi di buffer di uscita. I buffer di output catturano l'output fornito dal programma. Ogni nuovo buffer di output viene posizionato in cima a una pila di buffer di output e qualsiasi output fornito verrà catturato dal buffer sottostante. Le funzioni di controllo dell'output gestiscono solo il buffer più in alto, quindi è necessario rimuovere il buffer più in alto per controllare i buffer sottostanti.

Installazione

Le funzioni di controllo dell'output PHP fanno parte del core PHP. Non è richiesta alcuna installazione per utilizzare queste funzioni.


Configurazione di runtime

Il comportamento delle funzioni di controllo dell'output è influenzato dalle impostazioni in php.ini:

Name Default Description Version
output_buffering "0" Enables output buffering for all PHP files by default 4
output_handler NULL Set the name of the default function which handles the output of all output buffers 4
implicit_flush "0" Enables implicit flush, which causes output to be sent directly to the browser on each output statement 4
url_rewriter.tags "a=href,area=href, frame=src,form=,fieldset=" Indicates which HTML tags and attributes can be modified by the URL rewriter (the output_add_rewrite_var() function.) 4.3
url_rewriter.hosts The current value of $_SERVER['HTTP_HOST'] URL rewriting is only done on the server's own URLs by default. To allow for rewriting URLs of other websites, set the hostnames of the other websites here. 7.1

Funzioni di controllo dell'output PHP

Method Function
flush() Attempts to send content from the system's output buffer to the browser
ob_clean() Deletes all of the content from the topmost output buffer
ob_end_clean() Deletes the topmost output buffer and all of its contents
ob_end_flush() Deletes the topmost output buffer and outputs its contents
ob_flush() Outputs the contents of the topmost output buffer and clears the buffer
ob_get_clean() Returns all of the contents of the topmost output buffer and clears the buffer
ob_get_contents() Returns the contents of the topmost output buffer
ob_get_flush() Outputs and returns the contents of the topmost output buffer and then deletes the buffer
ob_get_length() Returns the number of bytes of data that are in the topmost output buffer
ob_get_level() Returns a number indicating how many output buffers are on the stack
ob_get_status() Returns information about the output buffers
ob_gzhandler() Used as a callback function for ob_start() to compress the contents of the buffer when sending it to the browser
ob_implicit_flush() Turns implicit flushing on or off
ob_list_handlers() Returns an array of callback function names that are being used by the topmost output buffer
ob_start() Creates a new output buffer and adds it to the top of the stack
output_add_rewrite_var() Used to append query string parameters to any URL in the output
output_reset_rewrite_vars() Removes all variables added by output_add_rewrite_var()