Whenever it is required to get some input url from user then the first things comes is check whether that url is working and valid or it is not working.
Here is a simple function which can be used to verify the liveness of the url.
Just pass the url to this function and it will tell you whether the url is working and valid or invalid.
In the function "check_url" we are going to open the given url with "fopen".
If its opened then return true else return false.
Now we are going to use this function.
you can pass the url from the GET or POST method to the function.
Here we are going to specify it directly in the code.
So we are asking our code to open the url http://www.chaprak.com with our function.
so after execution it will show the message as
http://www.chaprak.com is a valid URL.
See its very simple to check the validity of the url in php.
Full source code to try is here -
If you have any ideas and suggestions to improve this function then comments are always welcome.
Dont forget to tell your friends about http://programming-in-php.blogspot.com
Blogs I read
Categories
- php (32)
- php functions (9)
- Introduction (8)
- html (8)
- css (6)
- javascript (6)
- MySQL (2)
- firefox (2)
- php bugs-errors (2)
- php interview questions (2)
- MySQL functions (1)
Blog Archive
-
▼
2009
(45)
-
►
September
(14)
- Show random quotes on page every time a page is re...
- Split string with php explode function and print a...
- Caution while using JavaScript
- Javascript Acceleration
- This is for Horizontal Menu.
- Show random quotes on page refresh with php
- Display text file contents on webpage in php
- Factorial of a number in php
- Restrict the text in textarea - limit the length o...
- Generate a random password in php
- onclick select the text of a textarea
- Center all contents of website - cetering a websit...
- Javascript to show how many characters are remaini...
- PHP for converting numbers into words (upto one la...
-
►
August
(9)
- Simple css 1 level Vertical navigation menu
- Simple css 1 level horizontal menu
- Create a login box with css, html
- free php scripts and free php codes
- Create a database connection file in php mysql
- How to get ip in php ?
- Fill select tag with php - fill select tag of form...
- Show A-Z links for Pagination
- Warning: mysql_num_rows(): supplied argument is no...
-
►
September
(14)
Posted by
vaibhavsk
Nov 5, 2009
Labels:
php,
php functions
Subscribe to:
Post Comments (Atom)