Android Programmer Learning PHP Development (26)-Simple message Board-phpstorm

Source: Internet
Author: User
Tags learn php rtrim
Well, we finally have to deal with data storage, please forgive me to skip a lot of basic knowledge, is really a practical practice to wait ~ ~ Haha!

Simple message board, relying on TXT to store data, just an exercise. Next, let's start with the database, this post is just a warm-up.

Look at the effects and source code:


<?php/** * Simple Message board */$filename = "Message.txt"; Write//If the user commits, writes to the file, writes if (Isset ($_post[' Dosubmit ')) in a certain format {$mess = "{$_post[' username ']}| |". Time (). "| | {$_post[' title ']}| | {$_post[' content '}        [n] ";    Writemessage ($filename, $mess);        } function Writemessage ($filename, $mess) {$fp = fopen ($filename, "a");        Fwrite ($fp, $mess);    Fclose ($FP);    }//Read if (file_exists ($filename)) {//If the file exists Readmessage ($filename);        } function Readmessage ($filename) {$mess = file_get_contents ($filename);//file_get_contents () reads the entire file into a string $mess = RTrim ($mess, "[n]"); The RTrim () function removes whitespace characters or other predefined characters to the right of the string $arrmess = Explode ("[n]", $mess); The explode () function breaks the string into arrays of foreach ($arrmess as $m) {list ($username, $date, $title, $content) = Explode ("| | |" , $m);    The list () function is used to assign a set of variables in a single operation echo "<b>{$username}</b>". Date ("Y-m-d h:i"). "  {$title},{$content}<br>

The above is the Android programmer to learn PHP development (26)-Simple message Board-phpstorm content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • 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.