942,520 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 413
  • PHP RSS
Feb 4th, 2010
0

php

Expand Post »
how to write a php code such that a link specified must directly display the contents of the link in the browser..??

thanku,
Reputation Points: 10
Solved Threads: 0
Light Poster
divyakprabh is offline Offline
40 posts
since Sep 2009
Feb 4th, 2010
0
Re: php
how to write a php code such that a link specified must directly display the contents of the link in the browser..??

thanku,
The thing to remember is that browsers never interact directly with PHP code. PHP is server-side script. It is run on the server, which then sends html/css/javascript to the browser.

Therefore, we're dealing with an HTML issue, not a PHP issue. If your question means that you don't want the link to open a new window, you could leave off the "target" attribute in the anchor link (target="_blank" is the one that opens a new browser window).
PHP Syntax (Toggle Plain Text)
  1. <a href="/openthispage.php">Open this page</a>
(Above is labeled "PHP syntax" but it is really HTML syntax)
To do this within PHP tags, use the "echo" command -
<?php
$link = "<a href='/openthispage.php'>Open this page</a>";
echo $link;
?>
Last edited by compusolver; Feb 4th, 2010 at 11:34 am. Reason: Explaining that labeled PHP syntax is actually HTML
Reputation Points: 11
Solved Threads: 2
Light Poster
compusolver is offline Offline
31 posts
since Sep 2009
Feb 4th, 2010
0
Re: php
So if I understand correctly, you want to grab the contents of a web page, and display it in your browser?
The basic method of doing that is like this:
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. print(file_get_contents("http://example.com/"));
  3. ?>

The only problem with this is that it grabs the HTML exactly as it appears on the page, so any relative links will be broken. If the page uses relative linking, then you'd have to write a regular expression and use preg_replace().
Reputation Points: 11
Solved Threads: 5
Light Poster
Jerail is offline Offline
39 posts
since Feb 2010
Feb 4th, 2010
0
Re: php
What is the easy and fast way to learn PHP. and what are the basic requirements for it. I know only HTML. Plz suggest me. Thanks.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
james786 is offline Offline
2 posts
since Feb 2010
Feb 5th, 2010
0
Re: php
I think the best way to start learning is to go through the tutorials at http://w3schools.com/php/default.asp and/or http://www.tizag.com/phpT/.
Reputation Points: 11
Solved Threads: 5
Light Poster
Jerail is offline Offline
39 posts
since Feb 2010
Feb 5th, 2010
0
Re: php
Buy a good book and go through it at your own pace. Online tutorials are all well and good, but I find nothing beats a decent book when starting out. See O'Reilly/Sitepoint/Wrox.
Sponsor
Featured Poster
Reputation Points: 1034
Solved Threads: 929
Sarcastic Poster
ardav is offline Offline
6,557 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Guess it is too complex...
Next Thread in PHP Forum Timeline: Neeed Help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC