Uncategorized

Print array to a file

problem statement If you want to print an array to a file, follow the solutions provided below. solution 1 Either var_export or set print_r to return the output instead of printing it. You can then save $results with file_put_contents. Or return it directly when writing to file: solution 2 Try following code.

Download File to server from URL

All you have to do to download a file to your server is by following the solutions provided below. solution 1 Since PHP 5.1.0, file_put_contents() supports writing piece-by-piece by passing a stream-handle as the $data parameter: solution 2

How can I find the php.ini file used by the command line?

If you need to enable pdo_mysql in the EasyPHP environment, follow the steps below. solution 2 Unlike phpinfo() it will tell if it didn’t find/use a php.ini at all. And you can simply set the location of the php.ini. You’re using the command line version, so using the -c parameter you can specify the location for this particular run, e.g.

File Handling using PHP

This solution will guide the method to modify/delete the contents of a text file using PHP. solution 1. Using file_put_contents: If you want to append to the file instead of replacing its contents use: (file_out_contents is the simpler alternative to using the whole fopen complex.) solution 2 Write “” to a file to delete its contents. To delete contents …

File Handling using PHP Read More »

Upload a file using PHP

If you want to upload a file to a given folder, follow the solutions given below. solution 1 Below is one way to upload files, there are many other ways. solution 2 First, write your HTML code like this, and don’t forget to add enctype=”multipart/form-data” Then create a file name called upload.php

en English
X
Scroll to Top