<?php
/**
Reads a file one line at a time (when the file content is large, it applies.) File_get_contents This scene is not very good)
$re = fopen ("index.php", "r+");
while (!feof ($re)) {
$char = fgets ($re);//Fgets gets a row, fgetc gets a character
Echo $char;
}
Fclose ($re);
**/
The second mandatory parameter of the fopen is the open mode;
/**
Multiple processes to write a file, to lock the mechanism
$file = fopen ("indexfile.php", "A +");//A + read and write append, w+ all the contents of the file, re-read and write;
if (Flock ($file, LOCK_EX)) {//Exclusive lock Exclusive
Fwrite ($file, "1111what is You doing\n");
Flock ($file, lock_un);//Release lock unlock
}else{
echo "Flock fail";
}
Fclose ($file);//The function actually calls the release lock
**/
/**
Get file name
Echo basename ("/data/www/test/filesystem.php"), "\ n";
Get directory Name
Echo dirname ("/data/www/test/filesystem.php"), "\ n";
echo __dir__, "\ n";
Manipulate a URL to get related information (note the use of PHP functions
$url _info = Parse_url (' Http://www.google.com/abc/xyz/fck.php?id=1#sharp ');//Parse_url processing URL is sufficient. The Second optional parameter is a PHP constant that takes a value directly from the array
Var_dump ($url _info);
$result = pathinfo ($url _info[' path ');//PathInfo () can info out some information such as file name, directory name, suffix name, etc.
Var_dump ($result);
Array (5) {
["Scheme"]=>
String (4) "http"
["Host"]=>
String "www.google.com"
["Path"]=>
String (+) "/abc/xyz/fck.php"
["Query"]=>
String (4) "Id=1"
["Fragment"]=>
String (5) "Sharp"
}
Array (4) {
["DirName"]=>
String (8) "/ABC/XYZ"
["BaseName"]=>
String (7) "fck.php"
["Extension"]=>
String (3) "PHP"
["FileName"]=>
String (3) "FCK"
}
**/
PHP operation file class function, operation URL, etc.