Main Menu

HOME

.Net
ASP
Assembly
C
C++
Delphi
HTML
Java
JavaScript Site
MySQL
PC interface
Powershell
Perl
PHP
VBScript
Visual Basic
XML

US Job listings




   Misc

   Amazon

   Links

PHP and cURL basic examples

 

OK we will show 2 basic examples, the first grabs a page of this site we have created and the second will grap google's homepage.

A word of warning do not use this in the second format unless you have permission from the website owner , the way I see this working is if you had several sites and perhaps wanted to display content from one of them in another.


 

 

Example1

<?php
$ch = curl_init("http://www.programmershelp.co.uk/curltest.php");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
?>

see it in action here

Example2

<?php
//the site or URL to get
$ch = curl_init("http://www.google.com/");
//set the options for the transfer
curl_setopt($ch, CURLOPT_HEADER, 0);
//execute the session
curl_exec($ch);
//free up system resources !!IMPORTANT
curl_close($ch);
?>

see it in action here


 




   Sponsors
 

   Software
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals

   Source Code
CDonts example(ASP)
check a directory exists(C Sharp)
Server info(PHP)
Blinking text(C)
Multicolored text(Javascript)
Pop up window(Javascript)
close any app(VB)
change the priority of a process(VBScript)




Copyright © 2004 by programmershelp.co.uk