Solved

Check if URL exists

Posted on 2010-08-30
7
302 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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Codeigniter Query Help Returning JSON 4 46
Unwanted output from my query 5 40
How Close unsubmited attempts 10 42
A responsive image gallery using flexbox 6 14
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
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.

740 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