Solved

Check if URL exists

Posted on 2010-08-30
7
298 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now