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

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

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.

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →