answersLogoWhite

0


Best Answer

PHP has a large number of functions which accommodate this. Primarily it sounds like you want to physically check that a page exists remotely by attempting to access it and dealing with the results.

If you are able to, the best solution would be to use the cURL extension which allows PHP to be a full-fledged browser of sorts - it knows about HTTP and can deal with the various issues that come up when checking a page exists (404 errors, etc). You would initiate a request to the provided URL and see if you get content or an error in reply.

The cURL documentation is at: http://www.php.net/manual/en/book.curl.php

If you cannot install extensions, it's OK - most PHP functions that accept filenames can also take URLs! For example, you could attempt loading the page using: $page = file_get_contents($URL). However, there's less definition as to what happens if the remote end provides a large 404 response, etc - so cURL would be preferrable.

Please keep in mind that any URL provided may be malicious: check with the parse_url() function to restrict to HTTP/HTTPS and keep "URLs" like file:///etc/passwd from succeeding!

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can you check if the URL exists using PHP?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Other Math

When using the POST method variables are displayed in the URL true or false?

False


What is a string of characters that points to a specific piece of information somewhere on the web?

URL


What is a linear sequence?

Hello, I see you are asking "What is linear sebaceous nevus sequence?" Linear nevus sebaceous syndrome (LNSS) is a condition characterized by the association of a large, linear sebaceous nevus (type of birthmark) with a broad range of abnormalities that may affect every organ system, including the central nervous system (CNS). The nevus usually is located on the face, scalp, or neck. For more information, you can visit this URL - skincarehealthcenter. com/condition/linear-sebaceous-nevus-sequence/c/26254


How do you make your 317 rsps online?

click start > cmd. and type:"ipconfig" now go to your cotrol panel and click on windows firewall > exceptions tab > add port: Portname: RSPS. Port: 43594. go to your web browser and put your 'gateway ip' into the URL and search. and a port into your router called 43594. and ending in 43594. then go to no-ip.com and make a account... but your external ip in there and host a ip of the port 43594. then compile it with java and the jdk version you have. and run your server. it's now online.


What calculator will find the square footage of an irregular shape?

SketchAndCalc, added to related links below. Performing such a calculation manually is indeed complex and time consuming. SketchAndCalc is an online Perimeter and Area calculator that allows the user to draw any regular or irregular shape with their cursor. The area and perimeter results are displayed when the shape is closed. The scale can be adjusted to accommodate very large areas such as the floor plan of a building, or the square meters area of a kitchen work surface or smaller. Using your cursor, draw the shape of any object. Line lengths are displayed below each line to ensure measurements are true. And they can be adjusted after the shape is complete. The area and perimeter results are then displayed. It has been compiled as an Adobe Flash component so the user may need to install the Adobe Flash browser plug-in. In addition, the tool offers a Sharing feature which allows the user to save the calculation as an URL to paste into an email or blog, and allow users to collaborate on the drawing as many times as they wish. This tool is currently free to use.

Related questions

How do you get the url in a php website?

Copy the URL with the .php, The .php is part of the page.


What is the GET method in PHP?

The GET method in PHP allows you to grab information from the URL to use in your script.For example, say you are on the URL index.php?id=1 you could then in the PHP script grab the id using the GET method to use in your script.


How do you get information from a form that is submitted using the get method?

In a form submitted using the GET method, the data is appended to the URL as query parameters. You can access this data using the $_GET superglobal array in PHP, or by parsing the URL in other programming languages.


What does curl stand for in php prgramming?

cURL - A Command line tool for getting or sending files using URL syntax


How do you give href toanother php page?

Here is the code below to redirect a webpage using php: <?php header('Location: url of the webpage'); // example: header('Location: index.php') exit; // exit after redirection is very important as php executes code line by line ?>


How do you get the URL domain name in PHP?

Using the $_SERVER superglobal array you can get the HTTP_HOST key which contains your domain, like so: $_SERVER["HTTP_HOST"]


What does php mean at the end of an url?

Websites are servers that present pages as they are requested. Pages, in this context, are merely different kinds of files -- much like images and word documents. The "php" appended at the end of a URL indicates you are requesting a PHP type file, which is composed with the PHP language. PHP is a programming language that stands for "PHP: Hypertext Preprocessor." It is used to develop websites that present dynamic content and allow page-to-page interaction, such as forums and wikis.


How do you redirect a url in php?

URL redirects occur when the server, ran by PHP, gives the client a new location to be at. This information is sent using a the HTTP Location header.Such a header can be sent using the header($str) function, where $strequals "Location: http://www.example.com/". This would send the client to example.com.Although uncommon, browsers can be configured to ignore location headers. Do not assume the client will always be redirected.


How do you save image url in database by using php?

If you can get the image url then just assign it to a php variable say: $image = (See related Link) Then you just have to add '$image' to the insert statement of your sql query Note: It would be better to store the folder path where your image is stored. That way your image will not be lost if your site moves to another server.


When using post method in php whether the variable displayed in url?

No, the variables do not form part of the URL visible in the address bar. They only display in GET methods or manually appended.To access POST variables in scripts, you need to use $_POST['variable_name'];


How do you copy and paste web page content using PHP coding?

file_get_contents($url) helps getting all the content of site.This function have some dependency on php.ini variable.


How do you upload an image to MySQL using PHP?

You cant upload an actual picture to MySQL, you can upload the URL but not the picture itself. You would have to upload this to your site first and then send the link to MySQL