# PHP: problem with using file\_get\_contents()

**URL:** https://forum.kirupa.com/t/php-problem-with-using-file-get-contents/242602
**Category:** programming
**Created:** [October 28, 2007, 1:43pm UTC](https://forum.kirupa.com/t/php-problem-with-using-file-get-contents/242602 "2007-10-28T13:43:19Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![silverType](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@silverType](https://forum.kirupa.com/u/silverType)
#### Post date: [October 28, 2007, 1:43pm UTC](https://forum.kirupa.com/t/php-problem-with-using-file-get-contents/242602/1 "2007-10-28T13:43:19Z")

</div>

Hi guys,

I have a problem with using the file\_get\_contents() method. My script is as follows:

```auto

<?php
	$url = "http://www.google.com/";
	$content = file_get_contents(urlencode($url)) or die("Can't open URL");
	echo $content;
?>

```

Whenever I run this script, it would fail with the “Can’t open URL” message. Any idea why it didn’t work? Thanks in advance.
