PHP Can Do. ไปหน้าเว็บ PHP Mindphp.com รูปแบบใหม่

PHP เขียนเว็บ เนื้อหา บทความ เขียนโปรแกรม สอน Code PHP

ค้นหาข้อมูลภายในเว็บ Mindphp.com
วัดความเร็วเน็ตทดสอบความเร็วอินเตอร์เน็ต บทความ php   เนื้อหา php  เขียน บทความ php  เว็บบอร์ด php   ค้นหา
พื้นที่โฆษณา
PHP เมนูหลัก
icon_home.gif Mind php.com
icon_poll.gif เนื้อหา php
tree-T.gif เนื้อหา php
tree-T.gif คู่มือ Function
tree-T.gif วารสารสมาชิก
tree-L.gif คู่มือ phpมีข้อมูลใหม่ !
favoritos.gif บทความ php
tree-T.gif บทความ PHP
tree-T.gif เขียนบทความ
tree-L.gif ค้นหา
icon_community.gif เว็บบอร์ด php
tree-T.gif Programming - PHP
tree-T.gif CMS, CRM,...
tree-L.gif Html Css
icon_members.gif VDO Tutorial
tree-L.gif Video PHP Tutorial
som_downloads.gif โหลด and ลิงค์
tree-T.gif PHP ดาวน์โหลด
tree-L.gif สารบัญเว็บ PHP
som_downloads.gif วัดความเร็วเน็ตมีข้อมูลใหม่ !
som_downloads.gif Pdf Creatorมีข้อมูลใหม่ !
icon_community.gif สมัครสมาชิก
PHP ตัวอย่าง บทความ
ติดตั้ง การใช้งาน Smarty templates
[ ติดตั้ง การใช้งาน Smarty templates ]
  • Smarty For Template Designers Programmers
  • กลุ่มบทความ PHP
  • AJAX - PHP (5)
  • CMS - PHP (6)
  • CRM - PHP (5)
  • Function PHP (8)
  • Google (5)
  • JavaScript (7)
  • Joomla (11)
  • Jquery (2)
  • OOP - PHP (6)
  • Pear Zend Framework (3)
  • PHP Editor (8)
  • PHP-Nuke (9)
  • Phpbb (2)
  • Smarty (1)
  • SQL - MySql (16)
  • ความรู้ทั่วไป (18)
  • เทคนิค การเขียน PHP (24)
  • บทความ PHP (8)
  • พื้นฐาน PHP (6)

  • fopen

    (PHP 4, PHP 5)

    fopenOpens file or URL

    Description

    resource fopen ( string $filename , string $mode [, bool $use_include_path= false [, resource $context ]] )

    fopen() binds a named resource, specified by filename , to a stream.

    Parameters

    filename

    If filename is of the form "scheme://...", it is assumed to be a URL and PHP will search for a protocol handler (also known as a wrapper) for that scheme. If no wrappers for that protocol are registered, PHP will emit a notice to help you track potential problems in your script and then continue as though filename specifies a regular file.

    If PHP has decided that filename specifies a local file, then it will try to open a stream on that file. The file must be accessible to PHP, so you need to ensure that the file access permissions allow this access. If you have enabled safe mode, or open_basedir further restrictions may apply.

    If PHP has decided that filename specifies a registered protocol, and that protocol is registered as a network URL, PHP will check to make sure that allow_url_fopen is enabled. If it is switched off, PHP will emit a warning and the fopen call will fail.

    Note: The list of supported protocols can be found in List of Supported Protocols/Wrappers. Some protocols (also referred to as wrappers) support context and/or php.ini options. Refer to the specific page for the protocol in use for a list of options which can be set. (e.g. php.ini value user_agent used by the http wrapper).

    On the Windows platform, be careful to escape any backslashes used in the path to the file, or use forward slashes.

    <?php
    $handle 
    fopen("c:\\data\\info.txt""r");
    ?>

    mode

    The mode parameter specifies the type of access you require to the stream. It may be any of the following:

    A list of possible modes for fopen() using mode
    mode Description
    'r' Open for reading only; place the file pointer at the beginning of the file.
    'r+' Open for reading and writing; place the file pointer at the beginning of the file.
    'w' Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
    'w+' Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
    'a' Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
    'a+' Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
    'x' Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call.
    'x+' Create and open for reading and writing; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call.

    Note: Different operating system families have different line-ending conventions. When you write a text file and want to insert a line break, you need to use the correct line-ending character(s) for your operating system. Unix based systems use \n as the line ending character, Windows based systems use \r\n as the line ending characters and Macintosh based systems use \r as the line ending character.
    If you use the wrong line ending characters when writing your files, you might find that other applications that open those files will "look funny".
    Windows offers a text-mode translation flag ('t') which will transparently translate \n to \r\n when working with the file. In contrast, you can also use 'b' to force binary mode, which will not translate your data. To use these flags, specify either 'b' or 't' as the last character of the mode parameter.
    The default translation mode depends on the SAPI and version of PHP that you are using, so you are encouraged to always specify the appropriate flag for portability reasons. You should use the 't' mode if you are working with plain-text files and you use \n to delimit your line endings in your script, but expect your files to be readable with applications such as notepad. You should use the 'b' in all other cases.
    If you do not specify the 'b' flag when working with binary files, you may experience strange problems with your data, including broken image files and strange problems with \r\n characters.

    Note: For portability, it is strongly recommended that you always use the 'b' flag when opening files with fopen().

    Note: Again, for portability, it is also strongly recommended that you re-write code that uses or relies upon the 't' mode so that it uses the correct line endings and 'b' mode instead.

    use_include_path

    The optional third use_include_path parameter can be set to '1' or TRUE if you want to search for the file in the include_path, too.

    context

    Note: Context support was added with PHP 5.0.0. For a description of contexts, refer to Stream Functions.

    Return Values

    Returns a file pointer resource on success, or FALSE on error.

    Errors/Exceptions

    If the open fails, the function an error of level E_WARNING is generated. You may use @ to suppress this warning.

    Changelog

    Version Description
    4.3.2 As of PHP 4.3.2, the default mode is set to binary for all platforms that distinguish between binary and text mode. If you are having problems with your scripts after upgrading, try using the 't' flag as a workaround until you have made your script more portable as mentioned below
    4.3.2 The 'x' and 'x+' option was added

    Examples

    Example #1 fopen() examples

    <?php
    $handle 
    fopen("/home/rasmus/file.txt""r");
    $handle fopen("/home/rasmus/file.gif""wb");
    $handle fopen("http://www.example.com/""r");
    $handle fopen("ftp://user:password@example.com/somefile.txt""w");
    ?>

    Notes

    Warning

    When using SSL, Microsoft IIS will violate the protocol by closing the connection without sending a close_notify indicator. PHP will report this as "SSL: Fatal Protocol Error" when you reach the end of the data. To work around this, the value of error_reporting should be lowered to a level that does not include warnings. PHP 4.3.7 and higher can detect buggy IIS server software when you open the stream using the https:// wrapper and will suppress the warning. When using fsockopen() to create an ssl:// socket, the developer is responsible for detecting and suppressing this warning.

    Note: When safe mode is enabled, PHP checks whether the directory in which the script is operating has the same UID (owner) as the script that is being executed.

    If you are experiencing problems with reading and writing to files and you're using the server module version of PHP, remember to make sure that the files and directories you're using are accessible to the server process.

    See Also


    Advertising unit Ads
    บทความ Mind php
    > ทดสอบความเร็วเน็ต
    > ดาวน์โหลด MSN 9.0
    > บทความ
     >> เช็คเลขบัตรประชาชน
     >> แบ่งหน้าแสดงผล โค้ดแบ่งหน้า แบ่งหน้า php
     >> PHP แปลงตัวเลข เป็น เงินบาท
     >> วิธีสมัคร และใช้งาน no-ip
     >> สร้างไฟล์ PDF ด้วย PHP
     >> การใช้ phpmyadmin
     >> การ Select ข้อมูล Joins 2 ตาราง
     >> การแก้ปัญหา ภาษาไทย MySql เป็น ????
     >> การติดตั้ง โมดูล php-nuke
     >> การอัพโหลดไฟล์ ด้วย php
     >> PHP OOP คืออะไร
     >> บทความ CRM
     >> Http คืออะไร
    กระทู้เด่น
     >> วิธีติดตั้ง XAMPP
     >> วิธีติดตั้ง Appserv
     >> วิธีติดตั้ง Joomla 1.5
     >> วิธีติดตั้ง phpbb
     >> บอร์ด phpBB3 ของไทย
     >> โปรแกรมแปลงไฟล์
    รวม Free Code PHP Class Script
    Unix Timestamp Coverter
    * รวม Code PHPClass
    * Wallpaper Sport & Tutorial
    เกมส์ Flash เครื่องบิน
    วิธีแก้ เข้า regedit ไม่ได้
    วิธีแก้เข้า task manager ไม่ได้
    ผู้ที่กำลังใช้งานอยู่
    ขณะนี้มี 33 บุคคลทั่วไป และ 0 สมาชิกเข้าชม

    ท่านยังไม่ได้ลงทะเบียนเป็นสมาชิก กรุณาสมัครที่นี่
    คลิปวีดีโอสอน
    hmailserver ทำ Mail Server ใช้ในองศ์กร ด้วยโปรแกรมฟรี

    โดย: mindphp
    เมื่อ: 08th Feb 2010
    เข้าชม: 22609
    ให้คะแนน: 1.00 โหวต: 1

    ติดตั้ง PHP5 แบบ FastCGI บน IIS7 Windows 2008 Server

    โดย: mindphp
    เมื่อ: 26th Jan 2010
    เข้าชม: 16702
    ให้คะแนน: 0.00 โหวต: 0

    วีดีโอสอน การใช้งาน Teamviewer ฉบับภาษาไทย ใน คลิป เป็น teamviewer เวอร์ชั่น 5

    โดย: mindphp
    เมื่อ: 15th Jan 2010
    เข้าชม: 29306
    ให้คะแนน: 3.33 โหวต: 6

    มาดู Android Review on Youtube กัน Android ระบบปฏิบัตการบนมือถือ

    โดย: mindphp
    เมื่อ: 12th Jan 2010
    เข้าชม: 13611
    ให้คะแนน: 0.00 โหวต: 0

    คู่มือการใช้ microsoft office 2007 วีดีโอ Tutorial สอนการใช้ microsoft office 2007

    โดย: mindphp
    เมื่อ: 12th Jan 2010
    เข้าชม: 24026
    ให้คะแนน: 5.00 โหวต: 2

    ส่วนประกอบของ photoshop ความสามารถของ โปรแกรม Photoshop Feature

    โดย: mindphp
    เมื่อ: 12th Jan 2010
    เข้าชม: 14313
    ให้คะแนน: 0.00 โหวต: 0

    วิธี Download Microsoft Office 2007 Free

    โดย: mindphp
    เมื่อ: 10th Jan 2010
    เข้าชม: 56817
    ให้คะแนน: 4.17 โหวต: 6

    คอมพิวเตอร์โน๊ตบุ๊ค วีดีโอเปรียบเทียบคอมพิวเตอร์โน๊ตบุ๊ค แต่ละเจ้าศึกษารายละเอียดก่อนเลือกซื้อ

    โดย: mindphp
    เมื่อ: 10th Jan 2010
    เข้าชม: 13464
    ให้คะแนน: 0.00 โหวต: 0

    คลิปแต่งรูป วีดีโอสอน แต่งรูป

    โดย: mindphp
    เมื่อ: 10th Jan 2010
    เข้าชม: 15068
    ให้คะแนน: 0.00 โหวต: 0

    Intel Core 2 Quad Q8400 - CPU Review

    โดย: mindphp
    เมื่อ: 25th Sep 2009
    เข้าชม: 17566
    ให้คะแนน: 3.00 โหวต: 1

    สนับสนุน Mindphp
    หน้าหลัก Mind php เข้าระบบ mind php เผยแพร่ข่าวสาร ดาวน์โหลด ติดต่อเรา สารบัญเว็บ กระดานข่าว php ค้นหา ลงโฆษณา ถาม/ตอบ
    BasLover.com
    ดิกชันนารี ไทย อังกฤษ
    http://เที่ยวฮ่องกง เพียง 11,900บาท--> {พูดคุยกีฬาไทย} insitejapan.com ThaiLandHotelForum hobbyinter.com [Download msn 9.0]


    การสร้างหน้าเอกสาร: 0.19 วินาที