PHP's File system function library

Source: Internet
Author: User
Tags chmod file system reference

BaseName

Returns a file string that does not contain a path.

Syntax: string basename (string path);

return value: String

Function Type: File access

Content Description: Remove the path and file string, and return a string containing only the filename. In the Windows family operating system, the path can be a slash (/) or backslash (\), and a diagonal (/) path in the UNIX-series operating system.

Usage examples

The $file variable value in the following example is "index.php"

<?php
$path = "/home/httpd/html/index.php";
$file = basename($path);
?>

Reference dirname ()

Chgrp

Change the group to which the file belongs.

Syntax: int chgrp (string filename, mixed group);

return value: Integer

Function Type: File access

Content Description This function is used to change the group the file belongs to, only the system administrator permissions can arbitrarily change the file belongs to the group, the rest of the users can only change their own files. Success returns TRUE, Failure returns false; in the Windows family operating system, this function returns true without doing anything.

Reference Chown () chmod ()

chmod

Change the properties of the file.

Syntax: int chmod (string filename, int mode);

return value: Integer

Function Type: File access

Content Description: This function is used to change the properties of the file. Success returns TRUE and Failure returns false. In the mode value, the system does not automatically add it to 0 to get the correct octal calculus, and to use it correctly, you can use the second line in the following example.

Usage examples

The next two lines are to set the file property to Rwxr-xr-x, but the second row is better.

<?
chmod("/mydir/myfile", 755 ); // mode 为十进位,可能有潜在错误
chmod("/mydir/myfile", 0755 ); // mode 为八进位,确定的属性值
?>

Reference Chown () chgrp ()

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.