PHP operation php file _php tutorial

Source: Internet
Author: User

Sounds a little dizzy, doesn't it?!! Use PHP to manipulate PHP pages. There is a small use, in a system may have individual small items inconvenience to the database, but we have to often call in other pages, but also need to update, then we can use this way to solve. I had a couple of minor problems, and I took half a day to fix it.

For example: The user needs to change a title, but it is not appropriate to create a table for the title alone. So I thought, write this variable into the php file for other pages to invoke. name.php file that requires the following:

$name = "title";

?>

The word "title" needs to be updated by the user. So how do we come to realize:

A simple submit information page add_name.php



A page that receives user submissions and processes addname.php

$name =$_post[name]; Receives the name value passed from the add_name.php.
if (empty ($name)) {//Determine if empty
?>

}else{
$filename = "name.php"; Defining Action Files
$delline = 2; Number of rows to delete
if (!file_exists ($filename)) {//Determine if the file exists
Die ("The specified file is not found! Operation interrupted! ");
}
$farray =file ($filename); Reads the file data into the array
for ($tmpa =0; $tmpa<>
if (($tmpa + 1) ==2) {//judging number of rows
$farray [$tmpa]= "$name 2 =" "". $name. ";"; *
Replace data from an existing row
}//re-organized data
$NEWFP. = $farray [$tmpa];
}
$fp = @fopen ($filename, "w") or Die ("Write Open file $filename failed");

We open the file in a written way.

@fwrite ($FP, $NEWFP) or Die ("file write Failed");

@fclose ($FP); Close File
}
?>

This code is just for testing with 117-202 1z0-043 1z0-042. It is laughable to write the nonstandard place!

This allows us to update the variables in the name.php file. Of course this is a rather stupid method (who makes me stupid). There are many ways to implement this requirement.

We use the escape character in one line of the tag, which is easy to say, but when I test it, it's a waste of time because of the method. Now paste the escape character into the following:

Escape character sequence meaning
NewLine (LF or ASCII characters 0x0A (10))
Enter (CR or ASCII character 0x0D (13))
Horizontal tab (HT or ASCII character 0x09 (9))
\ Backslash
$ dollar Sign
"Double quotation marks

[0-7] {1,3} This regular expression sequence matches a character represented by an octal symbol
x[0-9a-fa-f]{1,2} This regular expression sequence matches a character that is represented by a hexadecimal symbol


Single quotes are faster than using double quotes, so you have to select the appropriate quotation marks in your program.

http://www.bkjia.com/PHPjc/486631.html www.bkjia.com true http://www.bkjia.com/PHPjc/486631.html techarticle sounds a little dizzy, doesn't it?!! Use PHP to manipulate PHP pages. There is a small use, in a system may have individual small items inconvenience to the database, but we also often in ...

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