Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #5866
| From | "M. Strobel" <sorry_no_mail_here@nowhere.dee> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: reading a newline from a properties file |
| Date | 2012-05-09 09:50 +0200 |
| Message-ID | <a0uluaFdjeU1@mid.uni-berlin.de> (permalink) |
| References | <20447277.1852.1336486906498.JavaMail.geo-discussion-forums@ynff7> <12113687.988.1336542193956.JavaMail.geo-discussion-forums@vbpz13> |
Am 09.05.2012 07:43, schrieb taltene@gmail.com:
> בתאריך יום שלישי, 8 במאי 2012 17:21:46 UTC+3, מאת tal...@gmail.com:
>> Hi all.
>>
>> I need to write an HTTP response string in a properties file and read from a PHP file.
>>
>> For example:
>>
>> My_Response=HTTP/1.1 200 OK
>>
>> Server: gSOAP/2.7\
>>
>> Content-Type: text/xml; charset\=utf-8
>>
>> (etc.)
>>
>> Everything I tried failed: adding \n and \r\n inside the response line, writing the lines in seperate lines.
>>
>> When using one line with the formatting chars I always see those characters and not a real carrige return as I want.
>>
>> When I write the response in multiple lines, I only get the first line in response.
>>
>> I also added \ at the end of each line.
>>
>> Can you help please?
>>
>> Thanks!
>
> Thanks you all guys for your replies.
> The fact that the text is an HTTP response is of course not important. The issue is a text that should be in multiple lines.
> I added the real text because I though maybe there is a character that makes the problem.
>
> To those who asked: a proerties file is a file with key=value pairs. Thats all.
>
> So in my case the key is My_Response and the value is the http response string. Again - the meaning is irelevant.
>
> This is the function I use to try and read the value:
>
> ----------------------------------------
> Function ReadValueByKey ($PropFile, $PropKey) {
>
> print("ReadValueByKey\n");
>
> $Prop_Key = strtolower($PropKey);
> $Prop_File = file($PropFile);
>
> unset($Prop_Value);
>
> for($Counter = 0; $Counter < sizeof($Prop_File); $Counter++) {
>
> $Prop_Temp = trim($Prop_File[$Counter]); // Trim Prop line. Save the original var value to return it as result
> $Prop_Tmp = strtolower($Prop_Temp);
> //print("Prop_Tmp=".$Prop_Tmp."\n");
> if (substr_count($Prop_Tmp, $Prop_Key . "=") > 0) {
> $Prop_Value = substr($Prop_Temp, strlen($Prop_Key . "="));
> return $Prop_Value;
> }
> } // end for
>
> if ( !$Prop_Key ) {
> return "ERROR .: Key: or Variable: <b>".strtoupper($Prop_Key)."</b>, does not exist in <b>".strtoupper($PropFile)."</b> file !"; // Key or Variable NOT FOUND in Prop file
> }
> }
> --------------------------------------
>
Just a first impression:
this is old fashioned C in PHP, tampering with string lengths and substrings, error
prone. A regular expression would be cleaner.
/Str.
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
reading a newline from a properties file taltene@gmail.com - 2012-05-08 07:21 -0700
Re: reading a newline from a properties file The Natural Philosopher <tnp@invalid.invalid> - 2012-05-08 15:42 +0100
Re: reading a newline from a properties file "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2012-05-08 16:53 +0200
Re: reading a newline from a properties file "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-05-08 18:52 +0200
Re: reading a newline from a properties file Denis McMahon <denismfmcmahon@gmail.com> - 2012-05-08 17:33 +0000
Re: reading a newline from a properties file taltene@gmail.com - 2012-05-08 22:43 -0700
Re: reading a newline from a properties file "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-05-09 09:50 +0200
Re: reading a newline from a properties file "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2012-05-09 10:20 +0200
Re: reading a newline from a properties file "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2012-05-09 10:37 +0200
Re: reading a newline from a properties file taltene@gmail.com - 2012-05-09 04:21 -0700
Re: reading a newline from a properties file Jerry Stuckle <jstucklex@attglobal.net> - 2012-05-09 10:33 -0400
Re: reading a newline from a properties file taltene@gmail.com - 2012-05-09 22:56 -0700
Re: reading a newline from a properties file Jerry Stuckle <jstucklex@attglobal.net> - 2012-05-15 07:49 -0400
Re: reading a newline from a properties file Captain Paralytic <paul_lautman@yahoo.com> - 2012-05-09 05:26 -0700
Re: reading a newline from a properties file taltene@gmail.com - 2012-05-09 05:47 -0700
csiph-web