FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » file_get_contents() on Windows 7
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
file_get_contents() on Windows 7 [message #175439] Sun, 25 September 2011 17:22 Go to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
I am getting an error when using get_file_contents,
i simplified my problem as below:

C:\TEMP>dir >test

C:\TEMP>php -e "echo get_file_contents('test', true); "
Could not open input file: echo get_file_contents(test, true);

C:\TEMP>dir test
Volume in drive C is MyCdrive
Volume Serial Number is A0B0-B175

Directory of C:\TEMP

25-09-2011 19:09 1.822 test
1 File(s) 1.822 bytes


The question is, why?

I also tried to specify full path 'c:\temp\test'
or with slashes in stead of back-slased like: 'c:/temp/test'
but no luck so far.....

--
Luuk
Re: file_get_contents() on Windows 7 [message #175440 is a reply to message #175439] Sun, 25 September 2011 17:35 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 25-09-2011 19:22, Luuk wrote:
> I am getting an error when using get_file_contents,
> i simplified my problem as below:
>
> C:\TEMP>dir >test
>
> C:\TEMP>php -e "echo get_file_contents('test', true); "
> Could not open input file: echo get_file_contents(test, true);
>
> C:\TEMP>dir test
> Volume in drive C is MyCdrive
> Volume Serial Number is A0B0-B175
>
> Directory of C:\TEMP
>
> 25-09-2011 19:09 1.822 test
> 1 File(s) 1.822 bytes
>
>
> The question is, why?
>
> I also tried to specify full path 'c:\temp\test'
> or with slashes in stead of back-slased like: 'c:/temp/test'
> but no luck so far.....
>

C:\TEMP>php -v
PHP 5.3.6 (cli) (built: Mar 17 2011 10:37:07)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

(in can you want to know...)

--
Luuk
Re: file_get_contents() on Windows 7 [message #175441 is a reply to message #175439] Sun, 25 September 2011 17:28 Go to previous messageGo to next message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma: 0
Senior Member
On Sun, 25 Sep 2011 19:22:42 +0200, Luuk wrote:
> I am getting an error when using get_file_contents,
> i simplified my problem as below:
>
> C:\TEMP>dir >test
>
> C:\TEMP>php -e "echo get_file_contents('test', true); "
> Could not open input file: echo get_file_contents(test, true);

Where is your file "echo get_file_contents('test', true); "? It is
obviously not in the current directory.

>
> C:\TEMP>dir test
> Volume in drive C is MyCdrive
> Volume Serial Number is A0B0-B175
>
> Directory of C:\TEMP
>
> 25-09-2011 19:09 1.822 test
> 1 File(s) 1.822 bytes
>
>
> The question is, why?
>
> I also tried to specify full path 'c:\temp\test'
> or with slashes in stead of back-slased like: 'c:/temp/test'
> but no luck so far.....
>


--
4. Shooting is not too good for my enemies.
--Peter Anspach's list of things to do as an Evil Overlord
Re: file_get_contents() on Windows 7 [message #175442 is a reply to message #175441] Sun, 25 September 2011 18:27 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 25-09-2011 19:28, Peter H. Coffin wrote:
> On Sun, 25 Sep 2011 19:22:42 +0200, Luuk wrote:
>> I am getting an error when using get_file_contents,
>> i simplified my problem as below:
>>
>> C:\TEMP>dir>test
>>
>> C:\TEMP>php -e "echo get_file_contents('test', true); "
>> Could not open input file: echo get_file_contents(test, true);
>
> Where is your file "echo get_file_contents('test', true); "? It is
> obviously not in the current directory.

hmmmm,

too many errors on 1 line.... ;(

and its not even monday!

This works ok:
c:\TEMP>php -r "echo file_get_contents('test');"

>
>>
>> C:\TEMP>dir test
>> Volume in drive C is MyCdrive
>> Volume Serial Number is A0B0-B175
>>
>> Directory of C:\TEMP
>>
>> 25-09-2011 19:09 1.822 test
>> 1 File(s) 1.822 bytes
>>
>>
>> The question is, why?
>>
>> I also tried to specify full path 'c:\temp\test'
>> or with slashes in stead of back-slased like: 'c:/temp/test'
>> but no luck so far.....
>>
>
>


--
Luuk
Re: file_get_contents() on Windows 7 [message #175443 is a reply to message #175439] Sun, 25 September 2011 18:32 Go to previous messageGo to next message
Doug Miller is currently offline  Doug Miller
Messages: 171
Registered: August 2011
Karma: 0
Senior Member
On 9/25/2011 1:22 PM, Luuk wrote:
> I am getting an error when using get_file_contents,
> i simplified my problem as below:
>
> C:\TEMP>dir >test
>
> C:\TEMP>php -e "echo get_file_contents('test', true); "
> Could not open input file: echo get_file_contents(test, true);
>
[...]
> The question is, why?

Because that's not how you run PHP code from the command line.

Try using the -r flag instead.

Then you will discover that you have also misspelled the name of the
function. You have it spelled correctly in the title of your post, but
not in the PHP code shown above.
Re: file_get_contents() on Windows 7 [message #175444 is a reply to message #175442] Sun, 25 September 2011 18:39 Go to previous message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 25-09-2011 20:27, Luuk wrote:
> On 25-09-2011 19:28, Peter H. Coffin wrote:
>> On Sun, 25 Sep 2011 19:22:42 +0200, Luuk wrote:
>>> I am getting an error when using get_file_contents,
>>> i simplified my problem as below:
>>>
>>> C:\TEMP>dir>test
>>>
>>> C:\TEMP>php -e "echo get_file_contents('test', true); "
>>> Could not open input file: echo get_file_contents(test, true);
>>
>> Where is your file "echo get_file_contents('test', true); "? It is
>> obviously not in the current directory.
>
> hmmmm,
>
> too many errors on 1 line.... ;(
>
> and its not even monday!
>
> This works ok:
> c:\TEMP>php -r "echo file_get_contents('test');"
>
>>

i found the problem...

in my original code i was doing this to get the filename into $x:
$x = fgets($f);

and according to the manual the newline is included, so i had to strip
the last character of $x....


--
Luuk
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: [IJRRSIC] CALL FOR PAPERS Vol. 1 No. 4
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 01:25:49 GMT 2024

Total time taken to generate the page: 0.02683 seconds