1

here is what I'm trying to accomplish:

I have a file called url.php. When I access this file the only thing that shows up is a url.

I wanted to fetch this url and use it as a variable on a iframe in a different page.

Here is what I got:

<?php $myvar = file_get_contents('http://localhost/url.php'); echo "<iframe src='$myvar' height="1800px" width="1900px" frameborder="0"></iframe>"; ?> 

But it doesnt seem to be working.

Parse error: syntax error, unexpected T_LNUMBER, expecting 

Any suggestions? Thanks

0

2 Answers 2

2

You need to watch your double quotes.

echo "<iframe src='$myvar' height='1800px' width='1900px' frameborder='0'></iframe>"; 

You also may be having issues since you're using it on localhost:

PHP file_get_contents does not work on localhost

Sign up to request clarification or add additional context in comments.

7 Comments

That seems to work but it loads for a long time and doesnt update the iframe src url. The Src remains blank.
Just try echo $myvar; and see what comes through.
echo $myvar; doesnt show anything. So I assume there is something wrong with the file get contents
What happens when you visit the page in a web browser?
The page where im getting my var or the page with the loaded script?
|
0

When echo'ing with variables inside always double check your quotes.

Try this:

echo "<iframe src='".$myvar."' height='1800px' width='1900px' frameborder='0'></iframe>"; 

4 Comments

Seems like its not fetching properly the $myvar
Then its a problem with file_get_contents
Any suggestion what could be wrong with it? The url.php is displaying a URL as content just fine.
Post the content of the url.php, try also having them in the same directory and calling with relative path (without http://localhost)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.