Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> PHP
PHP
  1. PHP ErrorException

    บทนำคลาส Exception ของ PHP implement interface Throwable คลาส ErrorException extends คลาส Exception ErrorException นี้ใช้เพื่อโยนอย่างชัดเจนเมื่อต้องการ catch และจัดการ errors ที่จะถูกละเลยไป เช่น Notices หรือ WarningsPHP core มี predefined error constants ดังนี้ValueConstantDescription1E_ERRORFatal

  2. PHP DivisionByZeroError

    บทนำคลาส DivisionByZeroError เป็น subclass ของคลาส ArithmeticError ข้อผิดพลาดประเภทนี้เกิดขึ้นเมื่อ operation การหารมีค่า denominator เป็นศูนย์ สามารถเกิดขึ้นได้เมื่อ modulo operator (%) มี operator ตัวที่สองเป็น 0 และฟังก์ชัน intdiv() มี argument ตัวที่สองเป็น 0DivisionByZeroError Exampleในตัวอย่าง

  3. PHP CompileError

    บทนำตั้งแต่ PHP 7.3 เป็นต้นมา Exception CompileError ถูกเพิ่มเข้ามา คลาสนี้สืบทอดมาจากคลาส Error เงื่อนไขข้อผิดพลาดบางอย่างที่ก่อนหน้านี้ทำให้เกิด fatal error ตอนนี้โยน CompileError แทน ส่งผลต่อ compilation errors ที่อาจถูกโยนโดยฟังก์ชัน token_get_all()ฟังก์ชัน token_get_all() ใช้ Zend lexical scann

  4. PHP AssertionError

    บทนำคลาส AssertionError เป็น subclass ของคลาส Error ข้อผิดพลาดประเภทนี้ถูกโยนเมื่อ assert() คืนค่า FALSEassert() ตรวจสอบว่า assertion ที่ให้มาจริงหรือเท็จ และโยน AssertionError หากเป็นเท็จ ฟังก์ชัน assert() ถูกกำหนดดังนี้ไวยากรณ์for PHP 5 and PHP 7 assert ( mixed $assertion [, string $description ]

  5. PHP ArithmeticError

    บทนำคลาส ArithmeticError สืบทอดมาจากคลาส Error ข้อผิดพลาดประเภทนี้อาจเกิดขึ้นขณะทำ operation คณิตศาสตร์บางอย่าง หนึ่งสถานการณ์คือพยายามทำ bitwise shift operation ด้วยจำนวนลบ ข้อผิดพลาดนี้ยังถูกโยนเมื่อการเรียกฟังก์ชัน intdiv() ให้ผลลัพธ์ที่เกินขอบเขตที่ถูกต้องของ integerArithmeticError Exampleในตัวอ

  6. PHP ArgumentCountError

    บทนำPHP parser โยน ArgumentCountError เมื่อ arguments ที่ส่งให้ user-defined function หรือ method น้อยกว่าที่กำหนดใน definition คลาส ArgumentCountError สืบทอดมาจากคลาส TypeErrorArgumentCountError Exampleในตัวอย่างต่อไปนี้ ฟังก์ชัน user-defined add() ถูกกำหนดให้รับ 2 arguments แต่หากเรียกด้วย argumen

  7. PHP ArrayAccess Interface

    บทนำใน PHP Interface ArrayAccess ใช้สำหรับพัฒนาคลาสที่ให้การเข้าถึงแบบอาร์เรย์ (array-like access) ให้กับ property หนึ่งที่เป็นอาร์เรย์ Property อาร์เรย์ดังกล่าวสามารถจัดการได้โดยไม่ต้อง expose มันระหว่างการสร้าง object Interface ArrayAccess กำหนด abstract methods ดังนี้ไวยากรณ์ArrayAccess { abstrac

  8. PHP Closure Class

    บทนำAnonymous functions (หรือเรียกว่า lambda) คืนค่า object ของคลาส Closure คลาสนี้มีเมธอดเพิ่มเติมที่ให้การควบคุม anonymous functions เพิ่มเติมไวยากรณ์Closure { private __construct ( void ) public static bind ( Closure $closure , object $newthis [, mixed $newscope = static ] ) : Closure public bind

  9. PHP Generator Class

    บทนำการวนลูปข้อมูลจำนวนมากด้วย foreach ต้องการหน่วยความจำมากและเวลาประมวลผลนาน ด้วย generators สามารถวนลูปข้อมูลได้โดยไม่มี overhead เหล่านี้ Generator function คล้ายกับฟังก์ชันปกติ แต่แทน return statement จะใช้คำสำคัญ yield เพื่อ execute ซ้ำๆ จนกว่าจะหมดค่าที่จะวนลูปคำสำคัญ yield เป็นหัวใจของ gener

  10. PHP Iterator Interface

    บทนำInterface Iterator extends abstract Traversable interface PHP มี built-in iterators หลายตัว (เรียกว่า SPL iterators) สำหรับฟังก์ชันทั่วไป ตัวอย่างเช่น ArrayIterator, DirectoryIterator เป็นต้น คลาสของผู้ใช้ที่ implement Iterator interface ควร implement abstract methods ตามที่กำหนดไว้ไวยากรณ์Itera

  11. PHP IteratorAggregate Interface

    บทนำInterface IteratorAggregate extends abstract Traversable interface ถูก implement โดยคลาสเพื่อสร้าง external iterator Interface นี้มี abstract method หนึ่งชื่อ getIteratorไวยากรณ์IteratorAggregate extends Traversable { abstract public getIterator ( void ) : Traversable }เมธอดIteratorAggregate::ge

  12. PHP Serializable Interface

    บทนำInterface Serializable มีอยู่ใน PHP library เพื่อสร้างคลาสที่ให้การ serialize แบบกำหนดเอง ฟังก์ชัน serialize() ของ PHP สามารถ serialize ค่าส่วนใหญ่ให้เป็น representation ที่เก็บได้ แต่ object ของ user-defined classes ไม่สามารถ serialize ได้ Interface นี้ทำให้เป็นไปได้ไวยากรณ์Serializable { abstr

  13. PHP Throwable Interface

    บทนำใน PHP 7 Interface Throwable ทำหน้าที่เป็น base สำหรับออบเจกต์ใดๆ ที่สามารถเป็นพารามิเตอร์ของคำสั่ง throw รวมถึง Error และ Exception ทั้งคลาส Error และ Exception ซึ่ง predefined และ user-defined error/exception classes มาจากคลาสเหล่านี้ตามลำดับ implement Throwable interface เมธอด abstract ต่อไปน

  14. PHP Traversable Interface

    บทนำTraversable เป็น abstract interface จึงไม่สามารถ implement โดยตรงโดยคลาสใดๆ ได้ โดยทั่วไป Iterator หรือ IteratorAggregate interfaces ซึ่ง extends Traversable ถูกใช้เพื่อตรวจสอบว่าคลาสที่ implement สามารถวนลูปด้วย foreach ใน PHP ได้หรือไม่บางคลาส built-in ที่ implement interface นี้สามารถใช้ใน fo

  15. PHP WeakReference Class

    บทนำด้วย Weak references สามารถเก็บอ้างอิงไปยังออบเจกต์ได้โดยไม่ป้องกันไม่ให้ออบเจกต์ถูกทำลาย สามารถนำไปสร้างโครงสร้างแบบ cache ได้Weak reference คล้ายกับ normal reference แต่ไม่ป้องกันไม่ให้ garbage collector รวบรวมออบเจกต์ หากไม่พบ strong references ไปยังออบเจกต์นั้น มันจะถูกลบออกจากหน่วยความจำทัน

  16. PHP $argc

    บทนำSuperglobal variable นี้พร้อมใช้งานเมื่อรัน PHP script จาก command line (ไม่ใช่เมื่อรันจาก document root ของ HTTP server) เป็น integer ที่สอดคล้องกับจำนวน command line arguments ที่ส่งให้สคริปต์ปัจจุบัน เนื่องจากชื่อไฟล์สคริปต์ต้องพิมพ์ใน command line ค่าต่ำสุดของ $argc คือ 1 ตัวแปรนี้ไม่พร้อมใช

  17. PHP $argv

    บทนำเมื่อรัน PHP script จาก command line Superglobal array $argv จะมี arguments ที่ส่งให้ script ตัวแรกใน array $argv[0] จะเป็นชื่อของ script เสมอ ตัวแปรนี้ไม่พร้อมใช้งานหาก directive register_argc_argv ใน php.ini ถูกปิดใช้งาน$argvสคริปต์ต่อไปนี้ถูกรันจาก command lineตัวอย่าง<?php var_dump($argv)

  18. PHP $_COOKIE

    บทนำSuperglobal $_COOKIE เก็บตัวแปรที่ส่งมาพร้อม HTTP request ในรูปของ cookies $HTTP_COOKIE_VARS ก็มีข้อมูลเดียวกัน แต่ไม่ใช่ superglobal และถูก deprecated แล้วCookie คืออะไร?Cookies เป็นไฟล์ข้อความที่เซิร์ฟเวอร์เก็บไว้บนคอมพิวเตอร์ของ client และใช้เพื่อติดตาม (tracking) PHP รองรับ HTTP cookies อย่า

  19. PHP $_ENV

    บทนำ$_ENV เป็น superglobal associative array อีกตัวหนึ่งใน PHP เก็บตัวแปรสภาพแวดล้อม (environment variables) ที่พร้อมใช้งานสำหรับสคริปต์ปัจจุบัน $HTTP_ENV_VARS ก็มีข้อมูลเดียวกัน แต่ไม่ใช่ superglobal และถูก deprecated แล้วตัวแปรสภาพแวดล้อมถูกนำเข้าเข้าสู่ global namespace ส่วนใหญ่ของตัวแปรเหล่านี้ถ

  20. PHP $_FILES

    บทนำGlobal predefined variable $_FILES เป็น associative array ที่มีรายการไฟล์ที่อัปโหลดผ่าน HTTP POST method การอัปโหลดไฟล์ต้องการ HTTP POST method form ที่มี attribute enctype ตั้งเป็น multipart/form-data$HTTP_POST_FILES ก็มีข้อมูลเดียวกัน แต่ไม่ใช่ superglobal และถูก deprecated แล้วArray $_FILES ม

Total 1286 -คอมพิวเตอร์  FirstPage PreviousPage NextPage LastPage CurrentPage:55/65  20-คอมพิวเตอร์/Page Goto:1 49 50 51 52 53 54 55 56 57 58 59 60 61