Jump to content

[SOLVED] $var = file('http... gives parse error


johnnyboy

Recommended Posts

hello I get a parse error when I assign an external file to a variable.

 

I deleted the entire file except

<?php

$lines = file('http://www.example.com/myfile.txt');

?>

 

I get

Parse error: syntax error, unexpected T_VARIABLE in /home/restofpath/file.php on line 3

 

what gives, this example i took directly from the php manual

any help appreciated

 

johnny

 

 

Link to comment
https://forums.phpfreaks.com/topic/77522-solved-var-filehttp-gives-parse-error/
Share on other sites

PHP Manual: "You can use a URL as a filename with this function if the fopen wrappers have been enabled."

Possibly you can't open a remote location. Try file_get_contents for the URL.

 

Maybe the problem is related to the fact that 'http://www.example.com/myfile.txt' is a non-existent URL. Try a real URL.

pksml , thanks for the tips.

 

I changed the url because i did not want to post it here, but the one I use is a real url.

 

fopen works on my server, but I wanted to use file()

 

ok, I apologize for this post because I fear that I have just been an idiot.

 

there was a period in one of the blank lines that was causing the error

it now works fine.

 

thanks pksml

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.