Home php How to check if string is URL or not in PHP?

How to check if string is URL or not in PHP?

by Shahriar Sagor

Today now in this post i would like to show you How to check if string is URL or not in PHP? Sometimes, you have to check the given argument or string is URL or not, as specially sometimes we have to need check image column is url or not like. So now here i will give you an example of how to do this. If you have also need to do this then you can use filter_var() for solutions.

Example:

if(filter_var($imagePath, FILTER_VALIDATE_URL) === FALSE){
	print_r("Not valide URL");
}else{
	print_r("valide URL");
}

Read Also : How to convert Object into Array in PHP?

Thanks for read. I hope it help you. For more you can follow us on facebook.

close

You may also like