บทช่วยสอนPHP

PHP HOME แนะนำ PHP การติดตั้ง PHP PHP ไวยากรณ์ ความคิดเห็น PHP ตัวแปร PHP PHP Echo / พิมพ์ ประเภทข้อมูล PHP PHP Strings หมายเลข PHP PHP คณิตศาสตร์ ค่าคงที่ PHP ตัวดำเนินการ PHP PHP If...Else...Elseif PHP Switch PHP Loops ฟังก์ชัน PHP PHP Arrays PHP Superglobals PHP RegEx

แบบฟอร์มPHP

การจัดการแบบฟอร์ม PHP การตรวจสอบแบบฟอร์ม PHP ต้องใช้แบบฟอร์ม PHP URL แบบฟอร์ม PHP/อีเมล แบบฟอร์ม PHP เสร็จสมบูรณ์

PHPขั้นสูง

วันที่และเวลา PHP รวม PHP การจัดการไฟล์ PHP ไฟล์ PHP เปิด/อ่าน สร้าง/เขียนไฟล์ PHP อัพโหลดไฟล์ PHP คุกกี้ PHP PHP Sessions ตัวกรอง PHP ตัวกรอง PHP ขั้นสูง ฟังก์ชันเรียกกลับของ PHP PHP JSON ข้อยกเว้น PHP

PHP OOP

PHP OOP คืออะไร คลาส PHP/วัตถุ ตัวสร้าง PHP PHP Destructor PHP Access Modifiers PHP Inheritance ค่าคงที่ PHP PHP Abstract Classes อินเทอร์เฟซ PHP PHP ลักษณะ PHP Static Methods PHP คุณสมบัติคงที่ PHP เนมสเปซ PHP Iterables

ฐานข้อมูลMySQL

ฐานข้อมูล MySQL MySQL Connect MySQL สร้าง DB MySQL สร้างตาราง MySQL แทรกข้อมูล MySQL รับ ID ล่าสุด MySQL แทรกหลายรายการ MySQL ที่เตรียมไว้ MySQL Select Data MySQL Where MySQL สั่งซื้อโดย MySQL ลบข้อมูล ข้อมูลอัพเดต MySQL MySQL Limit Data

PHP XML

PHP XML Parsers PHP SimpleXML Parser PHP SimpleXML - รับ PHP XML Expat PHP XML DOM

PHP - AJAX

บทนำ AJAX AJAX PHP ฐานข้อมูล AJAX AJAX XML AJAX ค้นหาสด AJAX โพล

ตัวอย่างPHP

ตัวอย่าง PHP PHP คอมไพเลอร์ แบบทดสอบ PHP แบบฝึกหัด PHP ใบรับรอง PHP

ข้อมูลอ้างอิงPHP

ภาพรวม PHP PHP Array ปฏิทิน PHP PHP วันที่ ไดเรกทอรี PHP ข้อผิดพลาด PHP ข้อยกเว้น PHP ระบบไฟล์ PHP ตัวกรอง PHP PHP FTP PHP JSON คีย์เวิร์ด PHP PHP Libxml PHP Mail PHP คณิตศาสตร์ PHP เบ็ดเตล็ด PHP MySQLi เครือข่าย PHP การควบคุมเอาต์พุต PHP PHP RegEx PHP SimpleXML PHP Stream PHP String การจัดการตัวแปร PHP PHP XML Parser PHP Zip เขตเวลา PHP

ฟังก์ชันการควบคุมเอาต์พุต PHP


ฟังก์ชันการควบคุมเอาต์พุต PHP

PHP มีชุดของฟังก์ชันที่ควบคุมเนื้อหาที่จะส่งไปยังเบราว์เซอร์และเมื่อใด นี้เรียกว่าการควบคุมการส่งออก

ผลลัพธ์สามารถมาจากแหล่งใดแหล่งหนึ่งต่อไปนี้:

  • echo, print, printf, print_r... และฟังก์ชันและข้อความอื่นที่คล้ายคลึงกัน
  • ประกาศ คำเตือน และข้อผิดพลาดจาก PHP
  • เนื้อหาใด ๆ นอก<?php ?>แท็ก

PHP และแบ็กเอนด์ที่รันอยู่อาจเก็บเอาต์พุตไว้ในบัฟเฟอร์ก่อนที่จะส่งไปยังผู้ใช้

หมายเหตุ:ฟังก์ชันควบคุมเอาต์พุตสามารถสร้างบัฟเฟอร์เอาต์พุตจำนวนเท่าใดก็ได้ บัฟเฟอร์เอาต์พุตจับเอาต์พุตที่กำหนดโดยโปรแกรม บัฟเฟอร์เอาท์พุตใหม่แต่ละอันวางอยู่บนสแต็กของบัฟเฟอร์เอาท์พุต และเอาท์พุตใดๆ ที่มีอยู่จะถูกดักจับโดยบัฟเฟอร์ด้านล่าง ฟังก์ชันการควบคุมเอาต์พุตจะจัดการเฉพาะบัฟเฟอร์บนสุดเท่านั้น ดังนั้นจึงต้องลบบัฟเฟอร์บนสุดออกเพื่อควบคุมบัฟเฟอร์ที่อยู่ด้านล่าง

การติดตั้ง

ฟังก์ชันการควบคุมเอาต์พุต PHP เป็นส่วนหนึ่งของแกน PHP ไม่จำเป็นต้องติดตั้งเพื่อใช้ฟังก์ชันเหล่านี้


การกำหนดค่ารันไทม์

พฤติกรรมของฟังก์ชันการควบคุมเอาต์พุตได้รับผลกระทบจากการตั้งค่าใน 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

ฟังก์ชันการควบคุมเอาต์พุต 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()