Questions tagged [file-put-contents]

`file_put_contents()` is a PHP function which writes a string to a file.

file_put_contents() is a PHP function, introduced in PHP 5.1.0, which writes a string to a file. It was added as a shortcut and calling this function is identical to calling fopen(), fwrite(), and fclose() successively to write data to a file.

If the file attempting to be written to does not exist, the default behavior of the function is to create the file.

For more information on this function, please see the PHP manual: https://php.net/manual/en/function.file-put-contents.php

245 questions
-3
votes
1 answer

Issues with using file_get_contents and file_put_contents in PHP

I have to download an image in a weblink to my local folder using php. Below is the program.
-3
votes
2 answers

Caching JSON on server using expiration date?

This is some working code that I wrote to call a JSON file and cache it on my servers. I'm calling the cached file. If the file exists I use json_decode on it. If the file doesn't exist I then call the JSON and decode that. Then after calling the…
-3
votes
2 answers

How to write the current time to a new line of a .txt file on php execution

I want to log the execution of a php file on a .txt file. I want the file to look like this with serial number: 1, (time) 2, (time) 3, (time) . . . . . . . . . . where (time) is the time of execution of the php file. How to add the serial number to…
Saif
  • 2,530
  • 3
  • 27
  • 45
-4
votes
1 answer

why isn't file_put_contents working? (I use xampp)

file_put_contents is not working for the following code? (I used xampp) I try: $url = 'http://localhost/main_assets/images/company/news/142861-Spring-Break-main-pic.jpg'; $file_name = basename($url); echo "url:"; …
-5
votes
2 answers

PHP code as plain text

Is there a way to output PHP code as plain text? I have PHP code stored in my mysqli database, I want to fetch the PHP code and display it in a div. I don 't want the PHP code to be executed. Or is there a way to use file_put_contents() to fill a…
Henk de B
  • 55
  • 1
  • 8
1 2 3
16
17