Posts in Category: snippets

Clear the browser cache of CSS or JavaScript Using PHP

Other than caching every hour, or every week, you may cache according to file data.

or use file modification time:

or use file modification every hour:

or Using Javascript


Read More

PHP: fopen error handling

You should first test the existence of a file by file_exists().

or simple solution without exceptions:


Read More

PHP function to make slug (URL string)

Note: from WordPress

Use it like this:



Read More

Receive JSON POST with PHP

instead of

It will give you POST data as is. You will be able to decode it using


Read More

Current Site URL – Codeigniter

To get host url of current server simply replace




Read More

Random String PHP

Output the random string with the call below:


Read More

Adding divs to a foreach loop every 4 times

The output look like:



Read More