How to open a file for writing?



How to open a file for writing?..

Answer / Akash Mishra

To open a file for writing in PHP, use the `fopen()` function with the `'w'` mode:

```php
$myFile = fopen('filename.txt', 'w');
if (!$myFile) {
die('Unable to open file: ' . $myFile);
}
// write some content here...
fclose($myFile);
```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

Does facebook use php framework?

1 Answers  


How will you create a mysql database using php ?

3 Answers  


Explain what are some new features introduced in php7?

1 Answers  


What are the differences between include() and include_once () functions?

12 Answers  


Write a program using while loop in php?

1 Answers  


How to concatenate two strings together in php?

1 Answers  


Swap two variables value without using third variable in php ?

1 Answers   MCN Solutions,


What is inheritance in php with example?

1 Answers  


What is session_start () in php?

1 Answers  


What is array function in javascript?

1 Answers  


How to remove all duplicate values in array in php?

1 Answers  


How do I run a php script in windows?

1 Answers  


Categories