Solved

Check if URL exists

Posted on 2010-08-30
7
305 Views
Last Modified: 2013-12-13
I want to check if URL exits and all the examples that I found in the internet (file_exists, fsockopen, ..) and none of them worked.
0
Comment
Question by:VapiSoft
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 22

Accepted Solution

by:
Om Prakash earned 500 total points
ID: 33556322
Please check the following which uses curl_exec:
http://www.weberdev.com/get_example-4335.html

using header:
http://us3.php.net/manual/en/function.header.php
0
 
LVL 48

Expert Comment

by:hernst42
ID: 33556334
Or youcan use the stream extension. See http://www.php.net/manual/en/function.stream-get-meta-data.php
0
 

Author Comment

by:VapiSoft
ID: 33556443
I tried it, but I don't have the "curl_init(); " and all the other "cur..."
How do I get them?
0
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 

Author Comment

by:VapiSoft
ID: 33556455
to hernst42: I tried
$url="http://isragerb.narod.ru/bakajat.gif";
 if (stream_get_meta_data($url))
but I get the the parameter is invalid.
0
 
LVL 22

Expert Comment

by:Om Prakash
ID: 33556695
>>I tried it, but I don't have the "curl_init(); " and all the other "cur..." How do I get them?
You can enable this in php.ini file (for windows).
extension = php_curl.dll

in linux
extension = php_curl.so


0
 

Author Comment

by:VapiSoft
ID: 33556790
Hi om_prakash_p:

It works (and I will give you the points) but maybe you know what is the problem.
I get the following warrning:

Warning: curl_exec() [function.curl-exec]: Could not call the CURLOPT_HEADERFUNCTION in C:\wamp\www\MyTree\test1.php on line 53
0
 
LVL 22

Expert Comment

by:Om Prakash
ID: 33556944
this might be due to echo or print statements written before sending the request. try commenting the echo statements.

more examples:
http://php.net/manual/en/function.curl-exec.php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
?> 

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question