Hauv cov txheej txheem ntawm kev ua haujlwm, php-scripts tuaj yeem pom cov txiaj ntsig raws li tsab ntawv raug tua, lossis tsim cov ntaub ntawv, tos rau kev ua tiav ntawm tsab ntawv thiab ua tiav ntawm tsab ntawv. Cov kev xaiv ntawm ib qho ntawm cov kev xaiv nyob ntawm tus nqi muab rau hauv php tus neeg txhais lus cov chaw rau lub kuj tsis paub meej lub luag hauj lwm rau buffering cov ntaub ntawv tawm. Muaj ntau txoj hauv kev los hloov nws.
Cov Lus Qhia
Kauj ruam 1
Yog tias koj xav lov tawm cov zis rau txhua php ntawv sau ntawm lub server lossis hauv lub xaib, txoj hauv kev tseeb tshaj plaws los ua qhov no yog los ntawm cov ntaub ntawv php.ini. Thaum tso tawm txhua tsab ntawv, tus neeg txhais lus php nyeem cov lus teeb tsa los ntawm cov ntaub ntawv teeb tsa no, yog li tso rau hauv nws cov kev taw qhia kom tsis txhob cuam tshuam qhov tawm ntawm cov ntawv sau ntawm cov ntawv sau yog qhov kev daws teeb meem zoo tshaj plaws. Qhib cov ntaub ntawv hauv txhua cov ntawv nyeem nyeem thiab siv cov ntawv tshawb xyuas los nrhiav cov lus qhia hu ua output_buffering. Nws tus nqi tuaj yeem yog ib tus lej lossis cov zajlus sau (On lossis Off) kuj sib txawv, yog li hloov chaw tus nqi, nkag mus lossis 0.
output_buffering = Tawm
Kauj ruam 2
Yog tias koj xav lov tawm ntawm kev txiav txim siab rau cov ntawv sau rau cov ntawv sau cais lossis ib pawg ntawm subfolders, nws zoo dua los ua qhov no los ntawm cov ntawv htaccess. Nrhiav nws hauv cov ntawv qhia yam xav tau thiab qhib nws hauv phau ntawv kho. Yog tias tseem tsis muaj cov ntaub ntawv ntawd, tsim ib qho tshiab. Cov lus qhia uas yuav tsum tau ntxiv yog zoo li qhov uas tau piav qhia hauv qib dhau los, tab sis ua ntej nws koj yuav tsum tso cim tias qhov no yog ib qho ntawm php. Tag nrho cov kab yuav tsum zoo li qhov no:
php_flag output_buffering tawm
Muab cov htaccess tsim nyob rau hauv cov nplaub tshev loj ntawm cov ntawv qhia teeb tsa tus txheej txheem rau qhov kev taw qhia yog kom tau tua.
Kauj ruam 3
Yuav kom lov tes taw tsis nyob rau hauv ib tsab ntawv php, siv ib txoj haujlwm ntawm cov lus no. ob_get_flush () rov cov ntsiab lus tsis yog, tom qab ntawd nws xee tawm thiab tso cov zis tawm tsis tawm. ob_end_flush () tsis zoo ib yam, tab sis tsis rov qab cov ntsiab lus tam sim no ntawm qhov tsis mus rau lub npe uas hu ua nws, tab sis xa nws mus rau cov khoom siv ntaus ntawv tawm. Ob_end_clean () cias lwv cov ntaub ntawv tam sim no ua ntej tig los ua yeeb yaj kiab. Thaum siv ib qho ntawm cov haujlwm no, tsis txhob hnov qab tig thim rov qab - ob_start () muaj nuj nqi rau qhov no.