Replace HTML code of a webpage with PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
arjunetal
Forum Newbie
Posts: 2
Joined: Tue Dec 16, 2008 12:07 pm

Replace HTML code of a webpage with PHP

Post by arjunetal »

Hello everyone!!!
well I just want to know how can I replace the html code of a given webpage.
Like I want to change the code of a webpage whos address is http://www.xyz.com/abc.html
now i would like to change some code in it, to a different one....
can you give me the script for that {suppose the script is change.php
i would like to use it like this http://www.mysite.com/change.php?www.xyz.com/abc.html

i want outpur same as of http://www.xyz.com/abc.html, but with specific changes that i have coded in change.php

Thanks in Advance
Arjun Gupta
arjunetal@gmail.com
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Replace HTML code of a webpage with PHP

Post by John Cartwright »

Thats a very broad question. What have you tried so far?

Lets start simple. The first step is fetching the page contents, and I would recommend using cURL for this.

Code: Select all

 
$url = 'http://some_page_you_want_to_visit.com';
 
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //retrive output and do not display it
$content = curl_exec($ch);
Post Reply