Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #2307
| Message-Id | <2972164.SPkdTlGXAF@PointedEars.de> |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2011-06-23 09:55 +0200 |
| Subject | Re: Command line cannot fwrite, browser can |
| Newsgroups | comp.lang.php |
| References | (2 earlier) <Xns9F08B03825DEarbpenyahoocom@88.198.244.100> <iti559$vvt$1@dont-email.me> <Xns9F085CE966989arbpenyahoocom@88.198.244.100> <8855064.SEqChMirdb@PointedEars.de> <Xns9F0CD309DCAFAarbpenyahoocom@88.198.244.100> |
| Followup-To | comp.lang.php |
Followups directed to: comp.lang.php
Adrienne Boswell wrote:
> Thomas 'PointedEars' Lahn wrote:
>> Adrienne Boswell wrote:
>>> Jerry Stuckle writing:
>>>> Adrienne Boswell wrote:
>>>>> Thomas 'PointedEars' Lahn writing:
>>>>>>> $groupmail = fopen( $filename,'w' ) or die( 'cannot open
>>>>>>> groupmail.html' );
>>>>>> <http://www.phpfreaks.com/blog/or-die-must-die>
>>>>> Thank you for all your help, and the link. I have read it and will
>>>>> implement it.
>>>> I think you have another problem. Single vs. double quotes would
>>>> not make any difference in the code you posted.
>>> […]
>>> Yes, this is nagging me, too. I just checked it ran it right now (I
>>> also moved the script so it is not accessible to the WWW),
>>
>> This is not the World Wide Web, an application of the Internet, but
>> Usenet, a part of the Network News network (a growing part of which is
>> part of the Internet). So you may – SHOULD – as well post the
>> *relevant* *parts* of your working code here.
>
> Ok, here is the relavent piece of code (the relavent parts were snipped by
> Jerry).
ACK, thanks.
> Originally (with line numbers and I have replaced the real domain with
> example.com):
>
> 68 $filename = "C:\Inetpub\vhosts\example.com\httpdocs\groupmail
> \groupmail.html";
>
> 80 $groupmail = fopen( $filename,'w' ) or die( 'cannot open
> groupmail.html' );
>
>
> Warning:
> fopen(C:\Inetpub?hosts\example.com\httpdocs\groupmail\groupmail.ht ml):
> failed to open stream: Invalid argument in C:\Inetpub\vhosts
> \example.com\httpdocs\groupmail.php on line 80 cannot open groupmail.html
>
>
> So when I changed line 68 to:
>
> 68 $filename = 'C:\Inetpub\vhosts\example.com\httpdocs\groupmail
> \groupmail.html';
I can see the problem now. You have used the sequence "\v" in your string
literal. That makes the difference, because in double-quoted strings it is
parsed as a <VT> (vertical tab) character (that originates from early TTYs
and is hardly used nowadays, but kept for backwards compatibility [1]).
Hence the question mark in the warning after the "b" of "Inetpub", and the
missing "v" after it. <VT> is not one of the printable characters, so a
replacement character is used to display it.
In a single-quoted string, that and most other escape sequences carry no
special meaning [2]. So the path fits, and the file can be opened, then.
Since you cannot know beforehand which escape sequences are considered by a
certain version of PHP (other than `\\'), you should always escape literal
backslashes in string literals: "\\" or '\\' [2]. In fact, you MUST escape
them when at the end of the string value, because otherwise \" or \'
constitute escape sequences of themself, and the string value is not
terminated:
$ php -a
Interactive mode enabled
<?php echo "foo\";
^D
PHP Parse error: syntax error, unexpected $end, expecting T_VARIABLE or
T_DOLLAR_OPEN_CURLY_BRACES or T_CURLY_OPEN in - on line 2
$ php -a
Interactive mode enabled
<?php echo 'foo\';
^D
PHP Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE in - on
line 1
$ php -v
PHP 5.3.3-7+squeeze1 with Suhosin-Patch (cli) (built: Mar 18 2011 17:22:52)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with XCache v1.3.1, Copyright (c) 2005-2010, by mOo
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
[FYI: ^D stands for the keyboard shortcut Ctrl+D, which prints <ETX> (end of
text), an ASCII character (code point 0x03) that signals to the process that
the standard input stream is finished. It can also be used to `logout'
quickly from a unixoid shell.]
But for file paths you can replace the backslashes with forward slashes
(`/') even in WinDOS, which do not need to be escaped [3].
>> That puts into serious doubt whether you are worth getting further,
>> rather time-consuming, answers like the ones I give to you. Think
>> about that.
>
> One of the reasons I came here was because I have high respect for your
> knowledge.
Thank you.
> You might think that because I'm girl I have thin skin, but I don't.
All people are the same before PointedEars ;-)
> I have been around Usenet since 1996, so I have seen a lot,
> including your latest run-in with Jukka Korpela.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
What is that supposed to mean? (You may reply to this by PM.)
Please trim your quotes to the relevant minimum [4].
PointedEars
___________
[1] <http://en.wikipedia.org/wiki/Vertical_tab#Tab_characters>
[2] <http://php.net/manual/en/language.types.string.php>
[3] <http://php.net/fopen>
[4] <http://www.netmeister.org/news/learn2quote.html>
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300dec7@news.demon.co.uk> (2004)
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Command line cannot fwrite, browser can Adrienne Boswell <arbpen@yahoo.com> - 2011-06-17 21:22 +0000
Re: Command line cannot fwrite, browser can Denis McMahon <denis.m.f.mcmahon@gmail.com> - 2011-06-18 00:16 +0000
Re: Command line cannot fwrite, browser can Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-17 20:35 -0400
Re: Command line cannot fwrite, browser can Adrienne Boswell <arbpen@yahoo.com> - 2011-06-18 03:05 +0000
Re: Command line cannot fwrite, browser can Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-06-18 08:20 +0200
Re: Command line cannot fwrite, browser can Adrienne Boswell <arbpen@yahoo.com> - 2011-06-18 08:05 +0000
Re: Command line cannot fwrite, browser can Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-06-18 10:27 +0200
Re: Command line cannot fwrite, browser can Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-18 08:19 -0400
Re: Command line cannot fwrite, browser can Adrienne Boswell <arbpen@yahoo.com> - 2011-06-18 16:08 +0000
Re: Command line cannot fwrite, browser can Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-06-22 11:48 +0200
Re: Command line cannot fwrite, browser can Adrienne Boswell <arbpen@yahoo.com> - 2011-06-23 03:44 +0000
Re: Command line cannot fwrite, browser can Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-06-23 09:55 +0200
Re: Command line cannot fwrite, browser can Adrienne Boswell <arbpen@yahoo.com> - 2011-06-23 15:29 +0000
Re: Command line cannot fwrite, browser can Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-06-24 01:00 +0200
Re: Command line cannot fwrite, browser can Bernd Schulz <ask_me_for_email@invalid.invalid> - 2011-06-18 13:10 +0200
csiph-web