- 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 35163 Articles for Programming
439 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...
172 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
182 Views
The chgroup() function updates the file group. Remember that only the superuser has the authority to change the group of a file arbitrarily,Syntaxchgroup($file_path, group)Parametersfile_path − Set the path of file or directory to be checked. Required.group − Set the new user group name or number.ReturnThe chgroup() function returns.True, on success,False, on failureExampleThe following is an example that checks for file “one.txt” and changes its file group.OutputTRUE TRUE
302 Views
The basename() function gets the the filename component of a path. The file path is set as a parameter.Syntaxbasename(file_path, suffix)Parametersfile_path − Set the path of file or directory to be checked. Required.suffix − Set the extension of the file. Optional.ReturnThe basename() function returns the basename of the file.ExampleThe following is an example that checks for file “new.php” and returns the basename with the extension since we added the suffix parameter. Live DemoOutputnew.phpExampleLet us see another example that checks the file and display the basename without the extension. Live DemoOutputnew
452 Views
The file_exists method check whether a file or directory exists or not. It accepts the path of the file or directory to be checked as the parameter. The following are its uses −It is useful when you need to know whether a file exists or not before processing.With that, use this function while creating a new file to know whether the file already exists or not.Syntaxfile_exists($file_path)Parametersfile_path − Set the path of file or directory to be checked for existence.Required.ReturnThe file_exists() method returns.True, if the file or directory existsFalse, if the file or directory does not existExampleLet us see an example ... Read More
783 Views
A string is a one dimensional character array that is terminated by a null character. Concatenation of two strings is the joining of them to form a new string. For example.String 1: Mangoes are String 2: tasty Concatenation of 2 strings: Mangoes are tastyA program to concatenate two strings is given as follows.Example Live Demo#include using namespace std; int main() { char str1[100] = "Hi..."; char str2[100] = "How are you"; int i,j; cout
1K+ Views
A string is a one dimensional character array that is terminated by a null character. The reverse of a string is the same string in opposite order. For example.Original String: Apple is red Reversed String: der si elppAA program that reverses a sentence in the form of a string using recursion is given as follows.Example Live Demo#include using namespace std; void reverse(char *str) { if(*str == '\0') return; else { reverse(str+1); cout
To Continue Learning Please Login
Login with Google