Found 1466 Articles for PHP

fclose() function in PHP

Samual Sam
Updated on 24-Jun-2020 08:41:27

402 Views

The fclose() function closes an open file pointer. The function returns TRUE on success and FALSE on failure.Syntaxfclose(file_pointer)Parametersfile_pointer − The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen().ReturnThe fclose() function returns.TRUE on successFALSE on failureExampleOutputtrueLet us see another example. This shows a file which is opened, the content is returned using fgetsss and the file is closed with file pointer using file pointer.ExampleOutputThis is demo text

diskfreespace() function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 08:41:52

73 Views

The diskfreespace() function returns the available free space in a directory and is an alias of disk_free_space().Syntaxdiskfreespace(dir_name)Parametersdir_name − Directory to be specified.ReturnThe diskfreespace() function returns the free space in bytes.Example Live DemoOutput832931168256Let us see another example.Example Live DemoOutputFree Space: 832931168256

disk_total_space() function in PHP

Samual Sam
Updated on 24-Jun-2020 08:42:30

91 Views

The disk_total_space() function returns the total size of a directory. It returns the total number of bytes of a directory.Syntaxdisk_total_space(dir_name)Parametersdir_name − Specify the name of the directory.ReturnThe disk_total_space() function returns the total available space in bytes.Example Live DemoOutput944459485184Let us see another example.Example Live DemoOutputTotal Available Space: 944459485184

disk_free_space() function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 08:42:56

94 Views

The disk_free_space() function returns directory’s free space in bytes.Syntaxdisk_free_space(dir_name);Parametersdir_name − Specify the name of the directory.ReturnThe disk_free_space() function returns bytes of available space in a file. It returns false on failure.Example Live DemoOutput832806768640

dirname()function in PHP

Samual Sam
Updated on 24-Jun-2020 08:43:21

373 Views

The dirname() function returns the directory name from the specified path. If the path has no slashes, a dot ('.') is returned. This indicates the current directory.Syntaxdirname(file_path)Parametersfile_path − File to be specified.ReturnThe dirname() function returns the path of the directory.Example Live DemoOutputName of the directory: D:/amitLet us see another example.Example Live DemoOutputName of the directory: /amit

delete() function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 08:43:43

442 Views

The delete() function deletes a file. The path of the file to be deleted is to be specified as a parameter.Syntaxdelete(file_path)Parametersfile_path − Specify the path of the file to be deleted.ReturnThe delete() function returns.True, on successFalse, on failureExampleThe following is an example. This deletes the file “amit.txt” specified as a parameter.Outputtrue

copy() function in PHP

Samual Sam
Updated on 24-Jun-2020 08:44:06

1K+ Views

The copy() function copies a file. A copy of the source file to the destination file gets created. if the destination file is already present, it gets overwritten.Syntaxcopy(source_file, dest_file)Parameterssource_file − Set the file to copydest_file − Set the file to copy toReturnThe copy() function returns.TRUE, on successFALSE, on failureExampleOutputtrueLet us see another example now.Example Live DemoOutputfailed to copy /usr/home/guest/example.txt...

clearstatcache() function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 08:44:29

173 Views

The clearstatcache() function clears the file status cache.PHP caches the information returned by the following functions −stat()lstat()file_exists()is_writable()is_readable()is_executable()is_file()is_dir()filegroup()fileowner()filesize()filetype()fileperms()This is done to provide enhanced performance.Syntaxvoid clearstatecache()ParametersNAReturnNo value is returned by the clearstatcache() function.ExampleThe following is an example that checks for file “tmp.txt” and clears cache. Live DemoOutputCache cleared!

chown() function in PHP

Samual Sam
Updated on 24-Jun-2020 08:35:29

185 Views

The chown() function changes the file owner. Set a new owner for any file. This function won’t work for remote files.Syntaxchown($file_path, $user );Parametersfile_path − Set the path of file or directory to be checked. Required.user − Set the new owner name or id.ReturnThe chown() method returns.True, on successFalse, on failureExampleThe following is an example that set new owner for file “demo.txt”.Let us see another example, wherein a new user is set for file “new.txt”.Example

chmod() function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 08:36:25

374 Views

The chmod() function changes the file mode. It returns TRUE on success and FALSE on failure.Syntaxchmod($file_path, file_mode)Parametersfile_path − Set the path of file or directory to be checked for existence. Required.file_mode − Set the mode with values. The description of file_mode parameter is shown belowFile Mode parameterSet the file mode with the following four values.zeropermission for ownerpermission for the owner’s user grouppermissions for restThe following are the values to set multiple permissions. You need to add the following numbers −1 = execute permissions2 = write permissions4 = read permissionsReturnThe file_exists() method returns.True, on successFalse, on failureExampleThe following is an example ... Read More

Advertisements