Author name: admin

How to generate a random, unique, alphanumeric string in PHP?

In this solution, you will learn how to generate a random, unique, alphanumeric string in PHP. solution 1. PHP 7 standard library provides the random_bytes() function that generates cryptographically secure pseudo-random bytes. The above example will output something similar to: More info here solution 2. A quick, short, and to-the-point answer is: Which will generate …

How to generate a random, unique, alphanumeric string in PHP? Read More »

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 »

en English
X
Scroll to Top