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

 


Current Site URL – Codeigniter

To get host url of current server simply replace

application\config\config.php

with

 


PHP: fopen error handling

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

or simple solution without exceptions:

 


Random String PHP

Output the random string with the call below:

 


PHP function to make slug (URL string)

Note: from WordPress

Use it like this:

Code:

 





Receive JSON POST with PHP

instead of

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

later


Adding divs to a foreach loop every 4 times

The output look like: