Re: [PHP] is

2010-06-12 Thread Paul M Foster
On Fri, Jun 11, 2010 at 05:29:50PM -0400, tedd wrote:



> As for the Python "print" problem, I don't do Python -- so, it can
> win the lottery, or die, I don't care.

The issue, as I recall, is that for Python 3, they are changing print
(without parentheses) to require parentheses. This change alone (and
there are others like this in Python 3) will necessitate a *lot* of code
rewrites. Sometimes I wonder about Guido van Rossum.

>
> As for "don't embed a variable into a literal string and use
> preprocessing", as I said above, I often do this:
>
> 
>
> and find no problems whatsoever in doing so.
>
> However, I wouldn't do this:
>
> 
>
> OR, I would place a space before/after the . (i.e., 'The answer is '
> . $answer). However, I don't like doing that because I also program
> in other languages, which use the dot operator differently.

I tend to do it the way Tedd does, but I'm rethinking this. I recently
had occasion to do a lot of programming in C and Python, and one thing
stood out at me: I can't recall another language which allows
interpolation of variables within strings (without significant diddling,
if at all). It caused me great difficulty because I'm so used to doing
this in PHP. I can convert from '.' to '+' (as in most languages) in my
mind, but embedding variables in strings was a harder habit to break. My
opinion is that the dot operator used this way was a mistake for
PHP. Not using the dot operator to mean "concatenate" would mean we
could use it to replace the accursed '->' for class/method selection.
And the plus operator is obviously a more natural fit for string
concatenation.

And yes, if you're going to use the dot operator, surround it with
spaces for readability.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to change the first line of a text file

2010-06-12 Thread mcgiddin
The command would be something like this:

find /wwwdir -name \*.txt -print | xargs sed -i s/oldtext/newtext/gi

Matt


Sent via BlackBerry by AT&T

-Original Message-
From: Steve 
Date: Sat, 12 Jun 2010 15:24:39 
To: 
Subject: Re: [PHP] How to change the first line of a text file
On 6/12/2010 2:10 PM, Richard Kurth wrote:
>
> I have around 6000 text files and I need to change the first line on 
> every one of them.
>
> The first line is the title of the article and I need it look like 
> this the name of the article
>
> every file has the first line and the it starts the article on the 
> second line
>
> The files are in many directory under one main directory
> like this
>
> top directory
>fashion-school
>Dogs
>DentalAssistant
>etc..
>
> I need a script that will loop through each directory look at each 
> file extract the first line and replace it with the example above.
> I have figured out how to pull the first line into an array but I 
> don't no where to go from there to look in each directory and the 
> write the data back at the top.
>
> $f = file('GENERAL HISTORY OF DOGS.txt');
> $a = '' . $f[0] . '';
> echo $a;
>
>
>

Something like this should do what you want: http://pastebin.com/jKvAiGYa

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to change the first line of a text file

2010-06-12 Thread mcgiddin
If you're running on a *nix system you may want to look at using find, xargs, 
and sed.  Sorry I can't give you the syntax at the moment but you can google 
for the three of them and find several good examples.

Matt

Sent via BlackBerry by AT&T

-Original Message-
From: Steve 
Date: Sat, 12 Jun 2010 15:24:39 
To: 
Subject: Re: [PHP] How to change the first line of a text file
On 6/12/2010 2:10 PM, Richard Kurth wrote:
>
> I have around 6000 text files and I need to change the first line on 
> every one of them.
>
> The first line is the title of the article and I need it look like 
> this the name of the article
>
> every file has the first line and the it starts the article on the 
> second line
>
> The files are in many directory under one main directory
> like this
>
> top directory
>fashion-school
>Dogs
>DentalAssistant
>etc..
>
> I need a script that will loop through each directory look at each 
> file extract the first line and replace it with the example above.
> I have figured out how to pull the first line into an array but I 
> don't no where to go from there to look in each directory and the 
> write the data back at the top.
>
> $f = file('GENERAL HISTORY OF DOGS.txt');
> $a = '' . $f[0] . '';
> echo $a;
>
>
>

Something like this should do what you want: http://pastebin.com/jKvAiGYa

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to change the first line of a text file

2010-06-12 Thread Steve

On 6/12/2010 2:10 PM, Richard Kurth wrote:


I have around 6000 text files and I need to change the first line on 
every one of them.


The first line is the title of the article and I need it look like 
this the name of the article


every file has the first line and the it starts the article on the 
second line


The files are in many directory under one main directory
like this

top directory
   fashion-school
   Dogs
   DentalAssistant
   etc..

I need a script that will loop through each directory look at each 
file extract the first line and replace it with the example above.
I have figured out how to pull the first line into an array but I 
don't no where to go from there to look in each directory and the 
write the data back at the top.


$f = file('GENERAL HISTORY OF DOGS.txt');
$a = '' . $f[0] . '';
echo $a;





Something like this should do what you want: http://pastebin.com/jKvAiGYa

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to change the first line of a text file

2010-06-12 Thread Ashley Sheridan
On Sat, 2010-06-12 at 14:10 -0700, Richard Kurth wrote:

> I have around 6000 text files and I need to change the first line on every 
> one of them.
> 
> The first line is the title of the article and I need it look like this 
> the name of the article
> 
> every file has the first line and the it starts the article on the second 
> line
> 
> The files are in many directory under one main directory
> like this
> 
> top directory
> fashion-school
> Dogs
> DentalAssistant
> etc..
> 
> I need a script that will loop through each directory look at each file 
> extract the first line and replace it with the example above.
> I have figured out how to pull the first line into an array but I don't no 
> where to go from there to look in each directory and the write the data back 
> at the top.
> 
> $f = file('GENERAL HISTORY OF DOGS.txt');
> $a = '' . $f[0] . '';
> echo $a;
>  
> 
> 


Rather than use PHP for this I would look at using the find and sed
tools to edit the files.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] how to run pecl install pam

2010-06-12 Thread fakessh
hi list php
hi network php
hi all the guru of php


how to run pecl pam
I own a system centos 5.5 with deposits remi for php
what are the specific changes to /etc/pam.d/ and php.ini


and can you give me an example that works with all the details

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to change the first line of a text file

2010-06-12 Thread Richard Kurth


I have around 6000 text files and I need to change the first line on every 
one of them.


The first line is the title of the article and I need it look like this 
the name of the article


every file has the first line and the it starts the article on the second 
line


The files are in many directory under one main directory
like this

top directory
   fashion-school
   Dogs
   DentalAssistant
   etc..

I need a script that will loop through each directory look at each file 
extract the first line and replace it with the example above.
I have figured out how to pull the first line into an array but I don't no 
where to go from there to look in each directory and the write the data back 
at the top.


$f = file('GENERAL HISTORY OF DOGS.txt');
$a = '' . $f[0] . '';
echo $a;



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] is

2010-06-12 Thread tedd

At 5:28 PM -0700 6/11/10, Daevid Vincent wrote:

 > -Original Message-
 > From: Ahmed Mohsen [mailto:mre...@gmail.com]
 >

 Hey Daevid, does this form 
 improve anything in processing time or it's just for the sake of
 readability?


Technically it does have a microscopic speed increase, but unless you're
pumping out hundreds or thousands of lines (like in a loop) you most likely
won't notice it. In my code, I always try to use the proper quote marks
because I *am* dealing with huge tables of data. I've said this a hundred
times before, if you can shave off 0.001 from each row, then after 1,000
rows, you've shaved 1 second off the page time. That seems small, but that
shit adds up. Caching will help, as the page is already parsed once, so PHP
doesn't have to do the work again in many cases. To me, it's a good habbit
and costs you nothing to do.

The difference is that with " the PHP engine has to pre-process the string
and look to see if there's anything interesting it needs to do -- such as
replace any $var with their equivalents or \n or whatever else. A ' means
to use it as is, so PHP just spits it back out.


In my test comparing:

   $a = 'The answer is ' .$answer;

vs:

   $a = "The answer is $answer;"

I ran numerous test using 10,000,000 (10 million) operations each and 
the results never exceed 1/2 of a second difference, usually around 
1/3 of a second.


I realize that servers and conditions can change the results, but 
these results are what my server produced. I also realize there can 
be special conditions where one should consider speed, but seldom is 
the case where one needs to be concerned about pre-processing a 
string. The likelihood that it will present a problem is extremely 
remote. And these results are with today's speeds -- the difference 
will be less tomorrow and an order of magnitude less in a couple of 
years, or less.


I guess that what I am trying to say is pick considerations that are 
significant enough to have real merit. If you can show that your 
solution can be significantly improved by doing something a certain 
way, then more power to you. However, simply saying one way is better 
because it is faster, or uses less memory, doesn't carry the weight 
it once did. For example, it would have been nice if the net had been 
based on 8-bit instead of 7-bit, but the people who developed ASCII 
were concerned about memory. They were right for what they considered 
important at their time, but those concerns created a larger problem 
for the industry that followed. The significants of concerns change 
over time and not realizing that can create problems later.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Why is there HTML in the error_log output? Please make it stop.

2010-06-12 Thread Peter Lind
On 12 June 2010 11:23, Peter Lind  wrote:
> On 12 June 2010 01:17, Daevid Vincent  wrote:
>> I'm trying to clean up some code and have been looking at error_log output
>> and they all look like this:
>>
>> [11-Jun-2010 23:04:54] In
>> /var/www/my_notifications.php, line 40:  WARNING
>> Invalid argument supplied for foreach()
>> 
>>
>> I can't figure out:
>>
>>        [a] why the logs are in HTML format to begin with? Seems useless.
>>        [b] how do I turn it off and just be plain text (i.e. striptags()
>> )?
>>        [c] where is this  coming from?
>>
>> I've looked in /etc/php5/apache2/ and grepped through, but don't see 'red'
>> anywhere.
>>
>> I do see this, but it has no effect, as you can see by me 'disabling' it.
>>
>>  388 ; String to output before an error message.
>>  389 ;error_prepend_string = ""
>>  390 error_prepend_string = ""
>>  391
>>  392 ; String to output after an error message.
>>  393 ;error_append_string = ""
>>  394 error_append_string = ""
>>
>
> Did you check the html_errors directive?

Other thing that comes to mind is xdebug which will format error
output - not sure if that ends up in the error log though.

Regards
Peter


-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Why is there HTML in the error_log output? Please make it stop.

2010-06-12 Thread Peter Lind
On 12 June 2010 01:17, Daevid Vincent  wrote:
> I'm trying to clean up some code and have been looking at error_log output
> and they all look like this:
>
> [11-Jun-2010 23:04:54] In
> /var/www/my_notifications.php, line 40:  WARNING
> Invalid argument supplied for foreach()
> 
>
> I can't figure out:
>
>        [a] why the logs are in HTML format to begin with? Seems useless.
>        [b] how do I turn it off and just be plain text (i.e. striptags()
> )?
>        [c] where is this  coming from?
>
> I've looked in /etc/php5/apache2/ and grepped through, but don't see 'red'
> anywhere.
>
> I do see this, but it has no effect, as you can see by me 'disabling' it.
>
>  388 ; String to output before an error message.
>  389 ;error_prepend_string = ""
>  390 error_prepend_string = ""
>  391
>  392 ; String to output after an error message.
>  393 ;error_append_string = ""
>  394 error_append_string = ""
>

Did you check the html_errors directive?

Regards
Peter


-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php