A _php tutorial to write a simple message book without MySQL database support

Source: Internet
Author: User
Tags learn php readfile
Because the domestic MySQL resources are relatively tense, foreign is not too slow, is not open to our users. Therefore, in the days without MySQL, we want to do something convenient for others and improve their site, it is more difficult than the sky, in order to get rid of this pain, niky crying meditation, behind closed doors, finally, Emperor, a simple message that does not need MySQL database support, this has been introduced, Let's call it gbook.php, the source program is as follows:

if ($message)
{
$message = ereg_replace ("Rnrn", "N

", $message);
Remove invalid control symbols
$date = Date ("L, F J Y, h:i a"); Gets the specified date time format
$ip =getenv ("remote_addr");
$message = "














$name $email Written in--$date From >> $ip
$subject
$massage


";
$fp = fopen (basename ($PHP _self). ". Comment", "a");
Fwrite ($fp, $message);
Fclose ($FP);
}
@readfile (basename ($PHP _self. ". Comment")));
Read the contents of the record file
?>

──────────────────────────────────────
The above program, the principle is: on the PHP side first to determine whether the message variable exists, if not exist, read the file. The read file uses the ReadFile function. As for the file name extraction, here is a clever way to extract the absolute position of the file using the $php_self variable, and then use the basename () function to extract the filename, plus the specified end of the file comment.) to complete it. In order to better learn php&mysql, special take to share with you, but also hope that once and niky as painful as the network can have a message of their own, rather than "XXX message this is provided by xxx.com." and blot. What are you waiting for, hurry up and ACT!
All rights reserved, please do not reprint freely!
copyright©2000 Niky All rights reserved.

"The copyright of this article is owned by the author and house Orso near net, if need to reprint, please specify the author and source"

http://www.bkjia.com/PHPjc/316565.html www.bkjia.com true http://www.bkjia.com/PHPjc/316565.html techarticle because the domestic MySQL resources are relatively tense, foreign is not too slow, is not open to our users. Therefore, in the absence of MySQL days, we want to do some convenient others and improve their site ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.