Useful PHP functions – Part 1

At my web development, I have used a lot of PHP functions. Those functions are frequently used while development.So that today i have shared those function because it quite useful for the developers.

Validate email with PHP Filters:

it is a simple function to validate email and return bool value (true or false)

Validate URL is valid or not with PHP Filter:

it is same as email validate but change the Filter ID

PHP filter reference:

PHP filter ID reference:

Calculate Age from date of birth:

Just pass the date string argument as string and that date string is in “1989-05-30″ format.

Generate random password:

It generates random password string by default length is 8 and you can change it by passing length as argument.

Make Clickable URL:

it will process the text based url and return it make clickable url

String replace once:

By default PHP doesnot has like this type of replace of string. This function will  replace the first occurrence of the matched word.

Truncate by words:

It truncates the content by word count which is passed via arguments

Check Request in HTTPS:

If the request has https means then it will return true otherwise it return false.

Append http:// in url:

it add http:// when http:// missing in URL

 Simple Redirection function:

it is basic redirection function with 301 redirection support

Get Current URL:

it is very basic function get current url with PHP.

Get Client IP:

it is used to find the client IP by using PHP and it will return formatted IP.

Get Browser Language:

Easiest way to get browser language and it helps dynamic PHP websites for Language Translation

Create URL friendly Slug:

It will generate URL friendly slug.

I hope it is useful functions for development…..



Please don’t forget to share and subscribe to latest updates of the blog .