Note: For more information, see my blog. Example: knowledge points required for a text message board: 1. file Operation: file_put_contents (); file write function file_get_contents (); File Read function 2. string processing function explode (); splits the string into an array
Note: For more information, see my blog. Example: knowledge points required for a text message board: 1. file Operation: file_put_contents (); file write function file_get_contents (); File Read function 2. string processing function explode (); splits the string into an array
Note: For more information, see my blog.
Example: Text message board
Required knowledge points:
1. File Operations:
File_put_contents (); file write function
File_get_contents (); File Reading Function
2. string processing functions
Explode (); a function that splits a string into an array.
Implode (); a function that splits an array to a specified string.
3. Array
Foreach () traverses the Array
Unset () destroy variable
Global Array:
$ _ POST []
$ _ SERVER ["REMOTE_ADDR"]; // obtain the IP address of the client
Time (); // obtain the timestamp of the current system
Date (); date conversion function;
Directory structure:
==========================================
| -- Index. php: page for adding message
|
| -- DoAdd. php: get the message and execute the php file for the add operation.
|
| -- Show. php: display the message page
|
| -- Del. php: interface for deleting message
|
| --Liuyan.txt file used to store message information
Code implementation:
Index. php:
My message board
Add messages to my message board to View Messages
Add message
Add comments in doAdd. php
My message board
Add messages to my message board to View Messages
Add message
"; // File_put_contents (" liuyan.txt ", $ ly); the output will overwrite the previous message! // 4. The message is successfully output! Echo "message successful! ";?>
Show. php Message Display Section:
My message boardScript function dodel (id) {if (confirm ("are you sure you want to delete it? ") {Window. location = 'del. php? Id = '+ id;} script
Add messages to my message board to View Messages
View Messages
My message board
Add messages to my message board to View Messages
Delete message
Message Title |
Contact |
Message Content |
IP address |
Message time |
Operation |
= 8) {// 3. split the message with the @ symbol as one (split the message with the @ symbol into a message array) $ lylist = explode ("@@@", $ info); // 4. traverse the message array and parse each message again. foreach ($ lylist as $ k =>$ v) {$ ly = explode ("##", $ v ); echo"
"; Echo"
{$ Ly [0]} | "; Echo"
{$ Ly [1]} | "; Echo"
{$ Ly [2]} | "; Echo"
{$ Ly [3]} | "; Echo"
". Date (" Y-m-d H: I: s ", $ ly [4])." | "; Echo"
Delete | ";}}?>Delete del. php messages: