- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1466 Articles for PHP
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
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
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
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
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
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
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...
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!
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
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
To Continue Learning Please Login
Login with Google