Include URL in php

Hi,
How can i include URL in php? (for example www.google.com)
I have a problem with that on this server.
Thanks

sorry but i don’t know what do you want to do :S
do you want to open a url and get its contents, or what? :S

if your talking about
<?
include(‘http://…’);
?>

as said in the php configuration(create a page with next content <? phpinfo(); ?>)
you cant include external url, you can include /path/to/file/file.htm but not http://yoursit…/file.htm
sorry

http://www.google.com/search?client=opera&rls=en&q=php+include+file&sourceid=opera&ie=utf-8&oe=utf-8

yes you can include a external url, but only the html content,

$a=fopen(‘http://google.com’,‘r’);
$b = stream_get_contents($a);
echo $b;
fclose($a);

or

$a=file_get_contents(‘http://google.com’);
echo $a;

My form is using php script that has two files:

  1. settings.php
  2. contactform.php

The contactform.php reads settings php using php include function. If I read from above, my php script wont work on webhost server…?

If I want to make it work, can I just copy the content of settings.php and paste it inside contactform.php…?

Please help.
Ming

Yes you can just copy your settings.php and paste in your contactform.php but that’s not the problem with your script. Like I said in the other post, post your script if you want help. There can be alot of reasons why PHP mail() is not sending the email.

Sometimes I tried to put:

<? echo “<a href=“www.google.com”>Google</a>”;
?>

But dreadfully it doesn’t accept, I think php can’t include links with echo, now I will try to use the include () command

What you did there paladin, was put a link to google, all echo does is display the code (depending on what it is) on the webpage.
include() WILL work. The other option, is frames, but include() will look so much better and more professional.

You have to use single quotes when using HTML inside PHP.

<?php echo '<a href="www.google.com">Google</a>'; 
?>

That should work. :slight_smile:

No, there are two other options. (only one of which is good)

<?php echo “<a href=‘www.google.com’>Google</a>”;
?>

or the best option
<?php echo “<a href=“www.google.com”>Google</a>”;
?>

The problem with those other two methods is…well i will give an example cause it’s easier than explaining.

<?php echo ‘<a href=“www.tomssite.com”>Tom’s Site</a>’;
?>
^that will not work.

Also, as a side not, it looks better to do it this way

<?php echo ("<a href=“www.google.com”>Google</a>");
?>

What do you mean no? Mine does work, if you only want to echo the link to Google.

And the other codes you’re using like …

<?php echo '<a href="www.tomssite.com">Tom\'s Site</a>'; ?>

and problem fixed if you want to include **’ **in the name.

I meant no, as in, you don’t have to use single quotes. Double quotes would be the ‘proper’ way of doing it(not that it matters a whole lot since you can do it either way), but that’s why I did it using double quotes instead of just using single.

Ok, the double quotes don’t work i spent lot of time thinking about why php doesn’t show me the link

Thank you i’m a bit newbie in php

Did you try single quotes?

<?php echo '<a href="www.google.com">Google</a>';  ?>

Post your code.
There’s no reason why double quotes wouldn’t work, if done the way I showed.

i tried this in my apache and it doesn’t accept:

echo “<a href=“registre.html”>Tornar enrere</a>”;

echo “<a href=‘registre.html’>Tornar enrere</a>”; --> But this way accept

Another question the command include() print something in the screen?¿ what did he done

Yea, the second on is one way.
What was show as the best way (which it almost seems like some one wants to argue whether or not it is.) is slightly different than your first one.

echo ("<a href=“registre.html”>Tornar enrere</a>");

The slash basically strips the next character of it’s coding function, and since you’re echoing it out it instead tells it to just display it (in this case) as HTML.
If that makes sense.

The reason i’m pushing this way is because when I first started programming I used really sloppy coding practices, which causes a lot of problems. It is a long road to understanding and using the proper coding practices when you’ve been writing sloppy code, so it’s better to understand and use the best coding practices from the start.