Today, I ran into PHP constants.
__file__The problem.
Looked it up on the Internet. The following rules are summarized.
The dirname (__file___) function returns the path where the script is located.
For example, the file b.php contains the
PHP downloads and collects remote images to a local device
/**
* Download a remote image to a local device.
*
* @ Param string $ url remote file address
* @ Param string $ filename name of the saved file (if
Phpdirname (_ FILE _) obtains the absolute path of the current FILE. For example, the current file is placed under (d: www), and the file name is test. php. The test code is as follows :? Phpecho _ FILE __; obtain the absolute address of the current
Here we introduce the production of image verification code, the character verification code can refer to the following articles:
Click to open link
The production of the picture verification code is divided into three steps:
1. Make a picture
For security concerns,
You want to upload a picture at the same time, in the image of the directory automatically generated a blank HTM file.
The picture catalog is defined by time, so the directory is a bit more.
How does PHP implement this?
/**
* Download remote pictures to local
*
* @param string $url remote file address
* @param string $filename The file name after saving (the file name is randomly generated when empty, otherwise the original file name)
*
PHP Gets the current page URL path#測试网址: http://localhost/blog/testurl.php?id=5//Get domain name or host address echo $_server[' http_host ']. ""; #localhost//Get web address echo $_server[' php_self ']. ""; #/blog/testurl.php//Get URL number
Share a way for PHP to traverse the directory and return the statistics directory size.Code:PHP$dirname= "Test1"; //mkdir ($dirname);//Traverse A level directoryfunctionListdir ($dirname) { $ds=Opendir($dirname); while($file=Readdir($ds)) {
1. View the file information in the directory> LS//list View the file information in the current directory> ls-l or ll//to display the file information in a detailed list> ls-a//View all files (including hidden files)> Ls-al//View all files in a
1.os.popen Run the Shell List command
Copy Code code as follows:
def traversedirbyshell (path):
For f in Os.popen (' ls ' + path):
Print F.strip ()
2. Using the Glob module
Glob.glob (path) returns the file name with
Here to talk about the ink on the way the implementation of the weather, but first of all, I simply decompile and refer to some other online data to speculate on the principle of skin, here for reference only. If you have a better way, welcome to
With this applet, Phper will not have to manually delete the directory files on the computer, in the practice of PHP directory file operation can use this function, on this basis can also increase the Browsing folder directory, and then
Today I ran into the PHP constant __file__ problem.
Check it on the Internet. The following rules are summarized.
The dirname (__file___) function returns the path where the script resides.
For example, file b.php contains the following:
$basedir =
RmDir Delete Empty Directory
The code is as follows
Copy Code
?To delete a directory using the RmDir function$dirname = "Mydir"; Defining variablesRmDir ($dirname);?>
Delete directory successful reaction ture,
The most recent changes to the ASP suffix to PHP, because lazy in a change. Also think that PHP is the same as QT is a high-level language, the general high-level language has provided the content to be added to the search function. As a then, on
1. Open File function
fopen (): For opening a file, you need to specify open mode when opening
Open mode
If the file does not exist, it is not created automatically
R: Read-only mode opens and points the file pointer to the beginning of the file
Web development source code: PHP class for generating static pages. Classhtml {var $ dir; dirforthehtmls (without) var $ rootdir; rootofhtmlfiles (without): htmlvar $ name; html file storage path var $ dirname; specified folder name class html
{
Var
/** * Download remote picture to local * * @param $url string remote file Address * @param $filename string file name after save (the file name is randomly generated when empty, otherwise the original file name) * @param $fileType The file type
This article introduces the sample code of the Yilong mini-program framework component because it is in the online tourism industry and is more concerned about the OTA industry dynamics. a while ago, I studied and experienced Yilong's mini-program,
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.