[PHP] Re: PHP editor for linux

2008-08-25 Thread Swapnil Jain

Hi,

I use gPHPEdit and bluefish, it makes PHP easy.


--
Swapnil Jain
--
E-mail: [EMAIL PROTECTED]
MSN   : [EMAIL PROTECTED]
GTalk : [EMAIL PROTECTED]
Skype : sj1410
YIM   : sj1410




Shawn McKenzie wrote:

It flance wrote:

Hi,

What do you think is the best php editor for linux.

I'm using the Debian distribution.

Thanks


 


I use Aptana which is based on eclipse and has built-in HTML/JS/PHP?SVN 
stuff.  Also a cool plugin that lets you easily develop for the iPhone 
and preview it.


-Shawn


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



Re: [PHP] Re: PHP editor for linux

2008-08-25 Thread Shelley
Check the result at http://phparch.cn.

And you are encouraged to make your choice.


2008/8/19 Pavel [EMAIL PROTECTED]

 I use Zend Studio (shareware, but i couldn't find better things). There are
 some plugins for Eclipse,but if you used Zend before, you will be cunfused
 by
 that plugins...

 P.S. Sorry for my English...


 --
 ===
 С уважением, Манылов Павел aka [R-k]
 icq: 949-388-0
 mailto:[EMAIL PROTECTED]
 ===
 А ещё говорят так:
 В каждом толстом человеке сидит худой и требует, чтобы его выпустили.
-- Сирил Коннолли
 [fortune]




-- 
With best regards,
Shelley Shyan
http://phparch.cn


[PHP] file_exists() not working correctly?

2008-08-25 Thread Chris Haensel
Good morning list,

I have a _very_ simple function... it is as follows

/**/

function getgalimage($fzg) {
$folder =   bilder;
$imgname=   $fzg._1.JPG;
$checkimg   =   $folder./.$imgname;
if(file_exists($checkimg)) {
//echo 'img
src=mod_search_thumbs.php?bild='.$imgname.'fzg_nr='.$fzg.'';
echo 'img src='.$checkimg.'';
} else {
echo 'div style=display:block; padding:2px; border:1px
solid red;a href='.$checkimg.''.$checkimg.'/a/div';
}
}

/**/

Now, the folder bilder exists, and I pass the number 0002822 to the
function. Now it should check whether the image file bilder/0002822_1.JPG
exists. It never finds the image, even though it exists (I checked it many
times now)

Could you point out the obvious mistake I am making here? I have checked it
over and over again, and can't find any mistake. I know that sometimes you
get stuck in your code, and don't see the obvious. So I'd like to ask you
all to show me my error :o) I hope you can see something which I can't.

Thanks for your help!!

Chris



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



[PHP] Session time

2008-08-25 Thread Swapnil Jain

Hi,

how do i get the time for how much a particular session was active. i.e 
difference between session start and session end.


I am able to do it by getting the difference of logintime and 
logouttime. but what it the user


1) doesn't logout and close the browser
2) or the sessions end after timeout
3) or the computer shutdowns improperly.
4) may be some other reason..





--
Swapnil Jain
--
E-mail: [EMAIL PROTECTED]
MSN   : [EMAIL PROTECTED]
GTalk : [EMAIL PROTECTED]
Skype : sj1410
YIM   : sj1410


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



Re: [PHP] file_exists() not working correctly?

2008-08-25 Thread Chris

Chris Haensel wrote:

Good morning list,

I have a _very_ simple function... it is as follows

/**/

function getgalimage($fzg) {
$folder =   bilder;
$imgname=   $fzg._1.JPG;
$checkimg   =   $folder./.$imgname;
if(file_exists($checkimg)) {
//echo 'img
src=mod_search_thumbs.php?bild='.$imgname.'fzg_nr='.$fzg.'';
echo 'img src='.$checkimg.'';
} else {
echo 'div style=display:block; padding:2px; border:1px
solid red;a href='.$checkimg.''.$checkimg.'/a/div';
}
}

/**/

Now, the folder bilder exists, and I pass the number 0002822 to the
function. Now it should check whether the image file bilder/0002822_1.JPG
exists. It never finds the image, even though it exists (I checked it many
times now)


Try a full path:

$folder = '/full/path/to/bilder';

--
Postgresql  php tutorials
http://www.designmagick.com/


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



[PHP] Re: concatenating with . or ,

2008-08-25 Thread Colin Guthrie

Govinda wrote:

easy to find our about concatenating with . in the docs...
but not so with ,

what is the difference?


One works and the other you made up?

Comma is an argument separator, it does not concatenate strings. You may 
see some example code that passes two strings into a function and you 
are assuming it's concatenating them before passing them in, but it's not.


If you have any examples perhaps folks here can clarify for you?

Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



Re: [PHP] file_exists() not working correctly?

2008-08-25 Thread Carlos Medina

Chris schrieb:

Chris Haensel wrote:

Good morning list,

I have a _very_ simple function... it is as follows

/**/

function getgalimage($fzg) {
$folder=bilder;
$imgname=$fzg._1.JPG;
$checkimg=$folder./.$imgname;
if(file_exists($checkimg)) {
//echo 'img
src=mod_search_thumbs.php?bild='.$imgname.'fzg_nr='.$fzg.'';
echo 'img src='.$checkimg.'';
} else {
echo 'div style=display:block; padding:2px; border:1px
solid red;a href='.$checkimg.''.$checkimg.'/a/div';
}
}

/**/

Now, the folder bilder exists, and I pass the number 0002822 to the
function. Now it should check whether the image file 
bilder/0002822_1.JPG
exists. It never finds the image, even though it exists (I checked it 
many

times now)


Try a full path:

$folder = '/full/path/to/bilder';


Hi,
please show at your JPG or jpg lower or Uppercase at first. Check if the 
file really exists and your server can read of the directory


Regards

Carlos

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



Re: [PHP] file_exists() not working correctly?

2008-08-25 Thread Chris



That worked like a charm. Now, can you tell me why that exact same function
works with a relative path on another server and with a full path only on
this server? I am glad that it works, but would also like to understand why
:o)


Could be different document roots for apache, different environment 
settings, lots of things.


If you have a config variable for the base folder of your app, try to 
use that.


If you don't, then work out the path relative to the file this function 
is in.


$mydir = dirname(__FILE__);
$path_to_folder = $mydir . '/../../images/';

That way it's relative to the file the function is in and you don't have 
to change it each time you put it on a new server.


--
Postgresql  php tutorials
http://www.designmagick.com/


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



[PHP] Re: newbie Q: How to say, if the fileNAME is equal to..., or better yet, if the fileNAME ends with '.jpg'?

2008-08-25 Thread Colin Guthrie

Govinda wrote:

if (true == ($file=.jpg)) {


Watch out for this!

You're doing a test that is an assignment..

You are assigning the value .jpg to the variable $file. You are 
then comparing this to the value true and (due to the loose variable 
types) this succeeds.


Although some people consider it ugly, it is a *very* good practice to 
put the constants on the left hand side of the comparison like so:

   if (true == (.jpg=$file)) {

I've kept your error above, but if you try and run this code, you will 
get a syntax error.


The correct comparison is to do:
   if (true == (.jpg==$file)) {

Note the double ='s signs.


As you have VB experiences, this is different, but follows the 
conventions of a lot of languages (C, C++, C# etc.). VB inferred whether 
you wanted assignment or comparison depending on the context, but this 
came at the expense of not being able to nest complex statements.



Of course your example above could probably have been achieved by doing

 if (file_exists(.jpg)) {

but that's beside the point :)

Col



--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



Re: [PHP] Re: concatenating with . or ,

2008-08-25 Thread Nitsan Bin-Nun
Gosh, what a smart ass!
The comma can also concatenate string!
You may want to run the following lines:
?php
$a = 3;
$b = 5;
echo $a, abc, $b;
?

Regards, (I'm actually crying right now for guys like who showoff too
much..)
Nitsan

2008/8/25 Colin Guthrie [EMAIL PROTECTED]

 Govinda wrote:

 easy to find our about concatenating with . in the docs...
 but not so with ,

 what is the difference?


 One works and the other you made up?

 Comma is an argument separator, it does not concatenate strings. You may
 see some example code that passes two strings into a function and you are
 assuming it's concatenating them before passing them in, but it's not.

 If you have any examples perhaps folks here can clarify for you?

 Col

 --

 Colin Guthrie
 gmane(at)colin.guthr.ie
 http://colin.guthr.ie/

 Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
 Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]



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




RE: [PHP] file_exists() not working correctly?

2008-08-25 Thread Per Jessen
Chris Haensel wrote:

 That worked like a charm. Now, can you tell me why that exact same
 function works with a relative path on another server and with a full
 path only on this server? I am glad that it works, but would also
 like to understand why

Check the working directory as well as the permissions.




/Per Jessen, Zürich


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



Re: [PHP] Re: concatenating with . or ,

2008-08-25 Thread Robert Cummings
On Mon, 2008-08-25 at 11:08 +0300, Nitsan Bin-Nun wrote:
 Gosh, what a smart ass!
 The comma can also concatenate string!
 You may want to run the following lines:
 ?php
 $a = 3;
 $b = 5;
 echo $a, abc, $b;
 ?

This is not concatenation it is argument separation. No string is
concatenated. The output may appear concatenated, but no concatenation
occurred, merely the output of each argument occurred in sequence.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



RE: [PHP] file_exists() not working correctly?

2008-08-25 Thread Chris Haensel


-:-  -Original Message-
-:-  From: Chris [mailto:[EMAIL PROTECTED]
-:-  Sent: Monday, August 25, 2008 9:25 AM
-:-  To: Chris Haensel
-:-  Cc: php-general@lists.php.net
-:-  Subject: Re: [PHP] file_exists() not working correctly?
-:-
-:-  Chris Haensel wrote:
-:-   Good morning list,
-:-  
-:-   I have a _very_ simple function... it is as follows
-:-  
-:-   /**/
-:-  
-:-   function getgalimage($fzg) {
-:-$folder =   bilder;
-:-$imgname=   $fzg._1.JPG;
-:-$checkimg   =   $folder./.$imgname;
-:-if(file_exists($checkimg)) {
-:-//echo 'img
-:-   src=mod_search_thumbs.php?bild='.$imgname.'fzg_nr='.$fzg.'';
-:-echo 'img src='.$checkimg.'';
-:-} else {
-:-echo 'div style=display:block; padding:2px; border:1px
-:-   solid red;a href='.$checkimg.''.$checkimg.'/a/div';
-:-}
-:-   }
-:-  
-:-   /**/
-:-  
-:-   Now, the folder bilder exists, and I pass the number
-:-  0002822 to the
-:-   function. Now it should check whether the image file
-:-  bilder/0002822_1.JPG
-:-   exists. It never finds the image, even though it exists
-:-  (I checked it many
-:-   times now)
-:-
-:-  Try a full path:
-:-
-:-  $folder = '/full/path/to/bilder';
-:-
-:-  --
-:-  Postgresql  php tutorials
-:-  http://www.designmagick.com/
-:-
-:-
-:-  --
-:-  PHP General Mailing List (http://www.php.net/)
-:-  To unsubscribe, visit: http://www.php.net/unsub.php
-:-
-:-

That worked like a charm. Now, can you tell me why that exact same function
works with a relative path on another server and with a full path only on
this server? I am glad that it works, but would also like to understand why
:o)

Thanks for your help matey!

Chris



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



[PHP] Re: concatenating with . or ,

2008-08-25 Thread Colin Guthrie

Nitsan Bin-Nun wrote:

Gosh, what a smart ass!
The comma can also concatenate string!
You may want to run the following lines:
?php
$a = 3;
$b = 5;
echo $a, abc, $b;
?

Regards, (I'm actually crying right now for guys like who showoff too
much..)


Erm, I wasn't being a smart ass was I? Certainly didn't mean to be. I 
was aiming for some light humoured banter as is the style on this list. 
Sometimes I miss that target, and sometimes my comments are just s 
witty and clever than no-one gets them ;)


Incidentally, despite your bold claims that I'm at fault, you are 
actually wrong.


The comma here is simply separating the arguments passed to echo (which 
isn't really a function, more a language construct as it does not need 
the parenthesis required by a normal function call).


Your output will all appear (and thus it seems like concatenation) but 
there is no actual concatenation going on. You are simply passing in 
multiple arguments, all of which are output in order.


Col (who is crying for the guys who like to showoff when they think 
someone else has made a mistake but it actually backfires and blows up 
in their face)


--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



RE: [PHP] file_exists() not working correctly?

2008-08-25 Thread Chris Haensel


-:-  -Original Message-
-:-  From: Chris [mailto:[EMAIL PROTECTED]
-:-  Sent: Monday, August 25, 2008 9:49 AM
-:-  To: Chris Haensel
-:-  Cc: php-general@lists.php.net
-:-  Subject: Re: [PHP] file_exists() not working correctly?
-:-
-:-
-:-   That worked like a charm. Now, can you tell me why that
-:-  exact same function
-:-   works with a relative path on another server and with a
-:-  full path only on
-:-   this server? I am glad that it works, but would also
-:-  like to understand why
-:-   :o)
-:-
-:-  Could be different document roots for apache, different
-:-  environment
-:-  settings, lots of things.
-:-
-:-  If you have a config variable for the base folder of your
-:-  app, try to
-:-  use that.
-:-
-:-  If you don't, then work out the path relative to the file
-:-  this function
-:-  is in.
-:-
-:-  $mydir = dirname(__FILE__);
-:-  $path_to_folder = $mydir . '/../../images/';
-:-
-:-  That way it's relative to the file the function is in and
-:-  you don't have
-:-  to change it each time you put it on a new server.
-:-
-:-  --
-:-  Postgresql  php tutorials
-:-  http://www.designmagick.com/
-:-
-:-

Thanks mate! Appreciate your help!!

Have a great day all!

Chris



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



[PHP] Auto-generating a graphs Y scale

2008-08-25 Thread Richard Heyes
Can anyone give me some pointers for auto generating an appropriate Y
scale for a graph (eg a bar/line graph). Much like JPGraph does.

Thanks.

-- 
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] newbie Q: How to say, if the fileNAME is equal to..., or better yet, if the fileNAME ends with '.jpg'?

2008-08-25 Thread David Otton
2008/8/24 Govinda [EMAIL PROTECTED]:

 $ThisDir = getcwd()./thumbs;
 $DirHandle = opendir($ThisDir);
 if ($DirHandle = opendir($ThisDir)) {
   echo Directory handle: $DirHandle\n;
   echo Files:br /hr width=\25\%\ align=\left\ /;

 while ((false !== ($file = readdir($DirHandle)))  1) {
if (true == ($file=.jpg)) {
echo $filebr /;
}
}
closedir($DirHandle);
 }

 But instead of printing only the name of the file which is equal to
 .jpg, it seems to actually set the value of $file to .jpg on
 each iteration of the while loop, so what I get is a list of files all
 having the same name (.jpg) and their number is equal to the actual
 number of files in that dir (plus 2 - for the . and .. files).

 How to say, if the fileNAME is equal to..., or better yet, if the
 fileNAME ends with '.jpg'?

Hi, you've had a lot of responses to issues in your code snippet. I'm
just here to point out - for the sake of the archives, really - that
there are at least two more approaches you could take. PHP is one of
those languages where there's more than one way to do most things.

?php
$path = './thumbs/' . sql_regcase ( '*.jpg' );

foreach ( glob( $path ) as $filename )
{
echo {$filename}br/;
}

You can check the manual for full details, but briefly, sql_regcase()
returns a case-insensitive regular expression, and glob() returns an
array of filenames that match the path given to it (in this case
./thumbs/*.jpg).

?php
$dir = new DirectoryIterator( './thumbs/' );

foreach( $dir as $file )
{
if ( preg_match( /jpg$/i, $file-getFilename() ) )
{
echo $file-getFilename() . br/;
}
}

In this one, we're iterating over a DirectoryIterator object
(http://uk2.php.net/manual/en/class.directoryiterator.php) instead of
the output of glob(). RecursiveDirectoryIterator also exists, which
allows you to traverse an entire tree, rather than just one directory.

You've already been pointed to preg_match(), so I won't explain that one again.

-- 

http://www.otton.org/category/programming/php-tips-tricks/

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



Re: [PHP] newbie Q: How to say, if the fileNAME is equal to..., or better yet, if the fileNAME ends with '.jpg'?

2008-08-25 Thread Jochem Maas

Chris schreef:



if (stripos(strrev($file), gpj.) === 0) {
echo $file;   }

note the ===, 3 equals signs here is very important! check the docs 
for why.


== means 'equals', and === means 'is identical to'.
Seems like they would do the same thing when comparing '0' to 'the 
position in the string where that substr is found'.  Why not?


0 can mean false in php:


indeed, php is dynamically typed and happily auto-casts all of the place
without issue ... this can bite you in the ass if your not aware of how
php auto-casts various types, and which types have precendence.

the manual should help, additionally test your assumptions regularly on the 
cmdline
with snippets like:

php -r ' var_dump(( == false), (1 == 1), (two == 1), (two == false));'

using === o test equality force type to be checked as well as 'content' of
the given LH and RH expressions.


$found = 0;

if (!$found) {
  echo File not found;
}

If a substr comparison matches at char 0:

$string = '12345';
$pos = substr($string, '1');

then without the '===' it would give the wrong result as $pos would be 
converted to false in this example.





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



Re: [PHP] RE: Sale 79% OFF !!!

2008-08-25 Thread Jochem Maas

Ryan S schreef:

klip
I hate to admit to this, but some 15 years ago I was consulting for a 
company doing oil exploration in Nigeria and I received a very 
elaborate and believable Nigerian scam. It was complete with signed 
and official documents from both the Nigerian Government and the Bank 
of Nigeria.


I passed the proposal through two attorneys and the decision was to 
participate. Of course nothing happened and we did not lose anything. 
But the first Nigerian scams were very believable.

/klip

Heck! Always wanted to meet someone who feel for the Nigerian scams, would 
never have thought you would be the one Tedd!


he didn't fall for it, he demanded money upfront and the scammers evaporated.
now does that make tedd a scammer? :-P


Can you give me mroe details of the scam? Is it like the ones we get via email 
everyday or different?


signed and official documents from both the Nigerian Government and the Bank of 
Nigeria

and

two attorneys

if the scam passed the evil eye of 2 lawyers then I'd guess it was a little
better put together THAN YOUR AVERAGE N1GERIAN SCAM.

YOUR TRULY,

MR. JOCHEM DANIEL MAAS ESQ.



Cheers!
Ryan



  




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



Re: [PHP] newbie Q: How to say, if the fileNAME is equal to..., or better yet, if the fileNAME ends with '.jpg'?

2008-08-25 Thread David Otton
2008/8/25 David Otton [EMAIL PROTECTED]:

 You can check the manual for full details, but briefly, sql_regcase()
 returns a case-insensitive regular expression, and glob() returns an
 array of filenames that match the path given to it (in this case
 ./thumbs/*.jpg).

I should have mentioned that glob() accepts shell wildcard expansions,
not regular expressions. But in this case they're similar enough that
you can get away with a mix-and-match approach.

-- 

http://www.otton.org/

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



[PHP] index.php not autoloading in apache

2008-08-25 Thread Vince Sabio
I am running PHP v5.2.6 on an Apache v2.2 server. For some reason, 
Apache is not automatically loading index.php files, even when there 
is no other index.* file in the directory; it will throw a you do 
not have permission to access [directory] instead.


I have the following in my httpd.conf file:

LoadModule php5_modulelibexec/apache22/libphp5.so
php_value session.save_path /tmp/
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

In case it matters, the server OS is FreeBSD-7.0-RELEASE.

Any idea what the problem is? I mean, other than the wetware?

Muchas gracias

__
Vince Sabio  [EMAIL PROTECTED]

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



[PHP] Re: index.php not autoloading in apache

2008-08-25 Thread Carlos Medina

Vince Sabio schrieb:
I am running PHP v5.2.6 on an Apache v2.2 server. For some reason, 
Apache is not automatically loading index.php files, even when there is 
no other index.* file in the directory; it will throw a you do not have 
permission to access [directory] instead.


I have the following in my httpd.conf file:

LoadModule php5_modulelibexec/apache22/libphp5.so
php_value session.save_path /tmp/
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

In case it matters, the server OS is FreeBSD-7.0-RELEASE.

Any idea what the problem is? I mean, other than the wetware?

Muchas gracias

__
Vince Sabio  [EMAIL PROTECTED]

Hi Vince,
search (grep/find ) for DirectoryIndex: Statement

Regards

Carlos

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



Re: [PHP] index.php not autoloading in apache

2008-08-25 Thread Richard Heyes
Hi,

Simply add Directory index.php to your config. Eg:

LoadModule php5_modulelibexec/apache22/libphp5.so
php_value session.save_path /tmp/
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php

That's from meory so it may off, I don't think so though.

-- 
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] index.php not autoloading in apache

2008-08-25 Thread Richard Heyes
 Simply add Directory index.php to your config. Eg:

Oops, that should be:

DirectoryIndex index.php

-- 
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] php not reading file properly

2008-08-25 Thread Jochem Maas

sean greenslade schreef:

Well, if you really want to know, I have to go to many places that do not
have internet access. For those places, I have a PDA. I have Avantgo
software on the PDA, and I wanted it to be able to store a copy of the log
file to review it when I do not have internet access. All I needed was a
webpage to access it, and the Avantgo software automatically downloads a
copy of it before I leave.


I see. :-) I was worried that it was going to cause grief ... people
constantly looking at the output of that script would do no good for
your servers performance.

you must have good eyesight to be reading apache logs on a PDA :-P



On Sun, Aug 24, 2008 at 7:42 PM, Jochem Maas [EMAIL PROTECTED] wrote:


sean greenslade schreef:

 I have this snippet of code that is supposed to read the apache access log

and display it:
?php
   $myFile = /var/log/httpd/access_log;
   $fh = fopen($myFile, 'r');
   $theData = fread($fh, filesize($myFile));
   fclose($fh);
   echo
   This weeks apache log (clears every sunday morning):.
   substr($theData,0,2000);
?
For some reason, it displays the logs when I run the php file thru
terminal:
php -f /web/apache.php

but not when I access it thru the web. when I browse to it, it just
displays
the static text (This weeks apache log (clears every sunday morning):),
not the log text.


you fixed the problem, but I have to ask:

why on earth you want to do this?



Very confused,
zootboy








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



Re: [PHP] Re: concatenating with . or ,

2008-08-25 Thread tedd

At 11:08 AM +0300 8/25/08, Nitsan Bin-Nun wrote:

Gosh, what a smart ass!
The comma can also concatenate string!
You may want to run the following lines:
?php
$a = 3;
$b = 5;
echo $a, abc, $b;
?


Colin may be a smart ass, but I think you'll the rest of him pretty smart too!

Sometimes, it pays to understand what's being discussed, which was 
concatenating.


As such,

echo $a, abc, $b;

does not concatenating anything.

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



[PHP] Attributes vs. Accessors

2008-08-25 Thread Philip Thompson

Hi all.

Curious. Which do you prefer and why?

?php
class Hello {
public $hi;

function __construct () {
$this-hi = 'Well Hello There!';
}

function hi () {
return $this-hi;
}
}

$hello = new Hello ();

// Access the value this way...
echo $hello-hi;

// or the accessor...
echo $hello-hi();
?

For publicly-declared variables, do you access the attribute directly  
or use an accessor?


~Philip

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



Re: [PHP] Restore Leading Zeros in Zip Codes

2008-08-25 Thread Philip Thompson

On Aug 21, 2008, at 9:44 PM, Keith Spiller wrote:


Hi,

RE:  Restore Leading Zeros in Zip Codes

Does anyone happen to have a script that will restore the leading  
zeros in a mixed data set of 5 digit zip codes and 10 digit zip+4  
codes?  Any suggestions?


Thanks,

Keith


?php
$len = strlen ($zip);

if ($len  5) {
str_pad ($zip, 5, 0, STR_PAD_LEFT);
} else if ($len  9) {
str_pad ($zip, 9, 0, STR_PAD_LEFT);
}
?

Of course as others have mentioned, if you need to account for '-',  
then modify appropriately.


~Philip

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



Re: [PHP] Attributes vs. Accessors

2008-08-25 Thread Stut

On 25 Aug 2008, at 13:32, Philip Thompson wrote:

Curious. Which do you prefer and why?

?php
class Hello {
   public $hi;

   function __construct () {
   $this-hi = 'Well Hello There!';
   }

   function hi () {
   return $this-hi;
   }
}

$hello = new Hello ();

// Access the value this way...
echo $hello-hi;

// or the accessor...
echo $hello-hi();
?

For publicly-declared variables, do you access the attribute  
directly or use an accessor?


If it's a public member variable there is no need for plain accessor  
methods - they add no value. I feel the same about private variables  
with plain get and set accessors, there's just no point unless the  
accessors are doing more than setting and getting the internal variable.


-Stut

--
http://stut.net/

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



Re: [PHP] Auto-generating a graphs Y scale

2008-08-25 Thread tedd

At 10:01 AM +0100 8/25/08, Richard Heyes wrote:

Can anyone give me some pointers for auto generating an appropriate Y
scale for a graph (eg a bar/line graph). Much like JPGraph does.

Thanks.

--
Richard Heyes



Richard:

First, the y scale is the one that runs up and down and not right to left.  :-)

Second, the physical length of the y scale should be static and 
whatever you want it to be (i.e., 5 inches, 10 inches, etc.).


Third, to plot points along this axis simply take the maximum value 
found in their Y coordinate and divide that into the physical length 
of the Y scale, such as 10 inches/1500. That will give you a delta 
value by which you can multiply all values to get their position on 
the y scale.


Do the same for x, and you have a scatter graph. Do the same for x, 
sort x, connect the dots and you have a line graph. Do the same for x 
and provide a range for x and you have a bar chart.


Here's an example:

http://webbytedd.com/aa/stdev/

At least I think that's what you're asking.

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] newbie Q: How to say, if the fileNAME is equal to..., or better yet, if the fileNAME ends with '.jpg'?

2008-08-25 Thread Philip Thompson

On Aug 24, 2008, at 6:54 PM, Govinda wrote:

Should I send replies to just the list?, or is the etiquette to  
reply-to-all?


You will get different opinions from different people on the list.  
IMO, Reply-All is really annoying. Since I'm on the list, there's no  
need to reply to me - I'll get the email via the list.


However, it is personal preference. I think the big deal is to *at  
least* reply to the list - that way we can all learn from what's being  
said. =D


~Philip


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



Re: [PHP] Attributes vs. Accessors

2008-08-25 Thread Christoph Boget
 Curious. Which do you prefer and why?
 For publicly-declared variables, do you access the attribute directly or
 use an accessor?
 If it's a public member variable there is no need for plain accessor methods
 - they add no value. I feel the same about private variables with plain get
 and set accessors, there's just no point unless the accessors are doing more
 than setting and getting the internal variable.

Personally, I always use the accessor methods.

For the most part I agree with Stut -- they don't add much value.
Where it does add value, though, is in the eventuality you ever need
to change the attribute to a more restrictive visibility.  If you ever
run across this need (and I have a couple of times), the only thing
affected is the class; you don't have to worry about changing all of
your code using that class.  Conceptually, it is my preference to keep
a class as much of a black box as possible and accessor methods allow
for that.

thnx,
Christoph

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



Re: [PHP] Attributes vs. Accessors

2008-08-25 Thread Philip Thompson

On Aug 25, 2008, at 7:54 AM, Christoph Boget wrote:


Curious. Which do you prefer and why?
For publicly-declared variables, do you access the attribute  
directly or

use an accessor?
If it's a public member variable there is no need for plain  
accessor methods
- they add no value. I feel the same about private variables with  
plain get
and set accessors, there's just no point unless the accessors are  
doing more

than setting and getting the internal variable.


Personally, I always use the accessor methods.

For the most part I agree with Stut -- they don't add much value.
Where it does add value, though, is in the eventuality you ever need
to change the attribute to a more restrictive visibility.  If you ever
run across this need (and I have a couple of times), the only thing
affected is the class; you don't have to worry about changing all of
your code using that class.  Conceptually, it is my preference to keep
a class as much of a black box as possible and accessor methods allow
for that.

thnx,
Christoph


1 - Attributes
1 - Accessors

Do continue... Hehehe =P

~Philip


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



Re: [PHP] Attributes vs. Accessors

2008-08-25 Thread Stut

On 25 Aug 2008, at 13:54, Christoph Boget wrote:

]Curious. Which do you prefer and why?
For publicly-declared variables, do you access the attribute  
directly or

use an accessor?
If it's a public member variable there is no need for plain  
accessor methods
- they add no value. I feel the same about private variables with  
plain get
and set accessors, there's just no point unless the accessors are  
doing more

than setting and getting the internal variable.


Personally, I always use the accessor methods.

For the most part I agree with Stut -- they don't add much value.
Where it does add value, though, is in the eventuality you ever need
to change the attribute to a more restrictive visibility.  If you ever
run across this need (and I have a couple of times), the only thing
affected is the class; you don't have to worry about changing all of
your code using that class.  Conceptually, it is my preference to keep
a class as much of a black box as possible and accessor methods allow
for that.


In my experience that's pretty rare, but your mileage may vary. If it  
does happen you can simply implement __get and __set magic methods,  
which is far better from a code maintainability point of view than  
littering the class with pointless accessor methods just in case (IMHO).


-Stut

--
http://stut.net/

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



Re: [PHP] Adding a single php file to .htaccess.

2008-08-25 Thread tedd

At 5:05 PM +0300 8/24/08, Dotan Cohen wrote:

On one particular server, all *.html files are written in Python. I
uploading a few PHP files to the directory, but they must also have
.html extensions (they are replacing files that _were_ python, but it
is rather important that the filename stay the same and I'd rather
avoid rewrite). I figured that it would be easy enough to add a
separate line in .htaccess for each PHP file, but I'm not getting it
for some reason. This is the .htaccess line that lets the system parse
*.html files as Python:
AddHandler cgi-script .html

This is what I'm trying to add to have the system parse specific files as PHP:
AddType application/x-httpd-php filename.html

I know that I am doing something wrong, but I do not know what. Any
ideas? Thanks!

--
Dotan Cohen


Dotan:

This is what I use to force php to consider certain files:

# handler for phpsuexec..
FilesMatch \.(htm|html|css|tpl)$
 SetHandler application/x-httpd-php
/FilesMatch

I occasionally use php in css files and this works for that.

My understanding is that you could change the FilesMatch to whatever 
specific files you want. For example, if you had changed 
contact.html from Python to php it would read:


FilesMatch contact.html

Would that solve the problem?

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] Attributes vs. Accessors

2008-08-25 Thread Eric Butera
On Mon, Aug 25, 2008 at 8:32 AM, Philip Thompson [EMAIL PROTECTED] wrote:
 Hi all.

 Curious. Which do you prefer and why?

 ?php
 class Hello {
public $hi;

function __construct () {
$this-hi = 'Well Hello There!';
}

function hi () {
return $this-hi;
}
 }

 $hello = new Hello ();

 // Access the value this way...
 echo $hello-hi;

 // or the accessor...
 echo $hello-hi();
 ?

 For publicly-declared variables, do you access the attribute directly or use
 an accessor?

 ~Philip

I access directly to avoid pointless method calls for reads.  It'd be
nice if there were a way to define a public read-only mode, but in my
code it is more of a rule of thumb.  I'm pretty strict on what gets
public visibility though.

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



Re: [PHP] newbie Q: How to say, if the fileNAME is equal to..., or better yet, if the fileNAME ends with '.jpg'?

2008-08-25 Thread tedd

At 7:53 AM -0500 8/25/08, Philip Thompson wrote:

On Aug 24, 2008, at 6:54 PM, Govinda wrote:


Should I send replies to just the list?, or is the etiquette to reply-to-all?


You will get different opinions from different people on the list. 
IMO, Reply-All is really annoying. Since I'm on the list, there's no 
need to reply to me - I'll get the email via the list.


However, it is personal preference. I think the big deal is to *at 
least* reply to the list - that way we can all learn from what's 
being said. =D


~Philip



I usually hit Reply All and then remove all email addresses except 
for php-general.


In addition, I also trim the replies down to what's important -- I 
hate long-ass emails.


In fact, it would be great if I could just see my emails without the 
32 lines of header fluff that accompanies each one.


I'm using Eudora for the Mac and the first 32 lines of all my emails 
are the header and if I click the Blah Blah button (that's supposed 
to show the header information), then I get another 25 lines of 
header. That's 57 lines in total to get to the contents of the email 
-- far more than what I need/want.


I've checked all the preference setting numerous time trying to cut 
down on the length of my emails but had no luck. I have to scroll 
every email to read -- that's a pain.


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] Re: concatenating with . or ,

2008-08-25 Thread Yeti
So it is faster to output various strings using the , instead of .?

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



Re: [PHP] Adding a single php file to .htaccess.

2008-08-25 Thread Dotan Cohen
2008/8/25 tedd [EMAIL PROTECTED]:
 Dotan:

 This is what I use to force php to consider certain files:

 # handler for phpsuexec..
 FilesMatch \.(htm|html|css|tpl)$
  SetHandler application/x-httpd-php
 /FilesMatch

 I occasionally use php in css files and this works for that.

 My understanding is that you could change the FilesMatch to whatever
 specific files you want. For example, if you had changed contact.html from
 Python to php it would read:

 FilesMatch contact.html

 Would that solve the problem?

 Cheers,

 tedd


Thanks, as soon as I get to a place where I dare run SSH I will try
that. It looks to be just what I was looking for, thanks.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

ä-ö-ü-ß-Ä-Ö-Ü


Re: [PHP] Re: concatenating with . or ,

2008-08-25 Thread tedd

At 3:25 PM +0200 8/25/08, Yeti wrote:

So it is faster to output various strings using the , instead of .?


Faster -- faster than what?

The subject line says concatenating -- commas don't concatenate.  I 
think they make little commas some other way. :-)


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] php not reading file properly

2008-08-25 Thread sean greenslade
Yeah, well, I don't want everyone to view my logs. Only me. So it won't add
any unnecessary load to my server.

On Mon, Aug 25, 2008 at 8:04 AM, Jochem Maas [EMAIL PROTECTED] wrote:

 sean greenslade schreef:

 Well, if you really want to know, I have to go to many places that do not
 have internet access. For those places, I have a PDA. I have Avantgo
 software on the PDA, and I wanted it to be able to store a copy of the log
 file to review it when I do not have internet access. All I needed was a
 webpage to access it, and the Avantgo software automatically downloads a
 copy of it before I leave.


 I see. :-) I was worried that it was going to cause grief ... people
 constantly looking at the output of that script would do no good for
 your servers performance.

 you must have good eyesight to be reading apache logs on a PDA :-P



 On Sun, Aug 24, 2008 at 7:42 PM, Jochem Maas [EMAIL PROTECTED]
 wrote:

  sean greenslade schreef:

  I have this snippet of code that is supposed to read the apache access
 log

 and display it:
 ?php
   $myFile = /var/log/httpd/access_log;
   $fh = fopen($myFile, 'r');
   $theData = fread($fh, filesize($myFile));
   fclose($fh);
   echo
   This weeks apache log (clears every sunday morning):.
   substr($theData,0,2000);
 ?
 For some reason, it displays the logs when I run the php file thru
 terminal:
 php -f /web/apache.php

 but not when I access it thru the web. when I browse to it, it just
 displays
 the static text (This weeks apache log (clears every sunday
 morning):),
 not the log text.

  you fixed the problem, but I have to ask:

 why on earth you want to do this?


  Very confused,
 zootboy








-- 
Feh.


Re: [PHP] newbie Q: How to say, if the fileNAME is equal to..., or better yet, if the fileNAME ends with '.jpg'?

2008-08-25 Thread Philip Thompson

On Aug 25, 2008, at 8:16 AM, tedd wrote:


At 7:53 AM -0500 8/25/08, Philip Thompson wrote:

On Aug 24, 2008, at 6:54 PM, Govinda wrote:

Should I send replies to just the list?, or is the etiquette to  
reply-to-all?


You will get different opinions from different people on the list.  
IMO, Reply-All is really annoying. Since I'm on the list, there's  
no need to reply to me - I'll get the email via the list.


However, it is personal preference. I think the big deal is to *at  
least* reply to the list - that way we can all learn from what's  
being said. =D


~Philip



I usually hit Reply All and then remove all email addresses except  
for php-general.


Exactly what I do!

In addition, I also trim the replies down to what's important -- I  
hate long-ass emails.


[Snip!]

I've checked all the preference setting numerous time trying to cut  
down on the length of my emails but had no luck. I have to scroll  
every email to read -- that's a pain.


Apple Mail. It's by far the best email app I've seen/used. =D You can  
hide/view headers as desired.


~Philip


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



Re: [PHP] Re: concatenating with . or ,

2008-08-25 Thread Philip Thompson

On Aug 25, 2008, at 8:36 AM, tedd wrote:


At 3:25 PM +0200 8/25/08, Yeti wrote:
So it is faster to output various strings using the , instead of  
.?


Simply, yes.

Will it make a *huge* difference? Probably not.

~Philip

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



Re: [PHP] concatenating with . or ,

2008-08-25 Thread Thiago Melo de Paula
Govinda,

please, consider the following code:

?php
$brandA = 'Porshe';
$brandB = 'Jaguar';

$testA = $branA . $brandB; //testA will have the value PorsheJaguar

$testB = $branA , $brandB; //Returns a Parse error: syntax error, unexpected
',' in /test.php on line 7
?

With that, you can see that the comma isn't a concatenation symbol as the
period.

When you use it with echo, you're actually passing more than one argument to
the echo construct (why construct and not function? please, refer to
http://us.php.net/manual/en/function.echo.php to get more details).

My 2 cents on this great list.

Regards from Brazil.

Thiago Melo de Paula

On Mon, Aug 25, 2008 at 1:27 AM, Govinda wrote:

 easy to find our about concatenating with . in the docs...
 but not so with ,

 what is the difference?



Re: [PHP] newbie Q: How to say, if the fileNAME is equal to..., or better yet, if the fileNAME ends with '.jpg'?

2008-08-25 Thread Wolf
!-- SNIP --
 I'm using Eudora for the Mac and the first 32 lines of all my emails 
 are the header and if I click the Blah Blah button (that's supposed 
 to show the header information), then I get another 25 lines of 
 header. That's 57 lines in total to get to the contents of the email 
 -- far more than what I need/want.

Really, they still make Eudora?  Or is this an old copy on the MacIntosh IIe 
that you are running.  ;)

Wolf

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



Re: [PHP] Re: concatenating with . or ,

2008-08-25 Thread Thiago Melo de Paula
Hello Yeti!

This is a very good question, because it shows that you're interested in get
the max from your PHP codes.

In my research about php optimization, I couldn't find any relevant article
about this specific issue, but some sites tell us that using commas instead
periods on echo constructor would be faster.
I agree with that, because using the concatenation symbol, will cause PHP to
take steps to process the concatenation.
But I think (I never did any performances tests on this subject) that the
gain would be irrelevant on a general site.

Regards from Brazil.

Thiago Melo de Paula

On Mon, Aug 25, 2008 at 10:25 AM, Yeti [EMAIL PROTECTED] wrote:

 So it is faster to output various strings using the , instead of .?



Re: [PHP] Re: concatenating with . or ,

2008-08-25 Thread TG
I would guess that using the comma would be faster, as Thiago mentioned.   
It's just a blind dump of what's in those strings and it dumps the values 
in sequence directly to the output.   A concatenation actually involves 
temporary memory space for holding value A and value B then possibly a 
third memory space as a working area of the size strlen(value A) + 
strlen(value B).. possibly extra operations to figure out the strlen() of 
each then create the third memory space, etc, etc..  (actual way PHP 
handles this is unknown to me... just giving a theoretical example).

echo This,  is a , test;   //   blinding dumps each string to output

echo This  .  is a  . test;   // Creates a string This is a test then 
dumps it to output


But as always, the best way to find out is to create a script to perform the 
operations a couple thousand times each and record the times.

-TG

- Original Message -
From: Thiago Melo de Paula [EMAIL PROTECTED]
To: Yeti [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Date: Mon, 25 Aug 2008 11:07:41 -0300
Subject: Re: [PHP] Re: concatenating with . or ,

 Hello Yeti!
 
 This is a very good question, because it shows that you're interested in get
 the max from your PHP codes.
 
 In my research about php optimization, I couldn't find any relevant article
 about this specific issue, but some sites tell us that using commas instead
 periods on echo constructor would be faster.
 I agree with that, because using the concatenation symbol, will cause PHP to
 take steps to process the concatenation.
 But I think (I never did any performances tests on this subject) that the
 gain would be irrelevant on a general site.
 
 Regards from Brazil.
 
 Thiago Melo de Paula
 
 On Mon, Aug 25, 2008 at 10:25 AM, Yeti [EMAIL PROTECTED] wrote:
 
  So it is faster to output various strings using the , instead of .?
 
 
 


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



Re: [PHP] Re: concatenating with . or ,

2008-08-25 Thread Maciek Sokolewicz

Thiago Melo de Paula wrote:

Hello Yeti!

This is a very good question, because it shows that you're interested in get
the max from your PHP codes.

In my research about php optimization, I couldn't find any relevant article
about this specific issue, but some sites tell us that using commas instead
periods on echo constructor would be faster.
I agree with that, because using the concatenation symbol, will cause PHP to
take steps to process the concatenation.
But I think (I never did any performances tests on this subject) that the
gain would be irrelevant on a general site.

Regards from Brazil.

Thiago Melo de Paula

On Mon, Aug 25, 2008 at 10:25 AM, Yeti [EMAIL PROTECTED] wrote:


So it is faster to output various strings using the , instead of .?





Sara Golemon (one of the PHP devs) once wrote an article which covers 
(amongst others) this:

http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html

The bottom point: using a comma is slightly faster and uses slightly 
less memory (which may or not be significant, depending on the situation).


Do note though, that the ORDER of execution is different when comparing 
echo a().b().c(); vs. echo a(),b(),c() !! (with concatenation it will 
first execute ALL functions, and THEN concatenate them together. With 
commas it will start left, execute, output, and then continue to the 
right.). If you directly send something to the output from within those 
functions, you'll notice it. If you only return a string from it, you 
won't. :)


so:
?php
function a() {
   echo 'a';
   return 'a';
}
function b() {
   echo 'b';
   return 'b';
}

echo a().b();	// will return: abab (function a called, outputs a. 
Return value stored. function b called, outputs b. Return value stored. 
The two return values are concatenated, and sent to output)

echo \n;
echo a(),b();	// will return aabb (function a called, outputs a. 
Return value is also immediately sent to output. function b called, 
outputs b. Return value is also immediately sent to output)


I hope that clears it up a bit.
- Tul

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



Re: [PHP] concatenating with . or ,

2008-08-25 Thread Andreas J.

hi,
here it is described in detail:
http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html

Govinda schrieb:

easy to find our about concatenating with . in the docs...
but not so with ,

what is the difference?



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



Re: [PHP] Auto-generating a graphs Y scale

2008-08-25 Thread Richard Heyes
 First, the y scale is the one that runs up and down and not right to left.
  :-)


Yes I know.

 Second, the physical length of the y scale should be static and whatever you
 want it to be (i.e., 5 inches, 10 inches, etc.).

That gives a poor range IMO. JPGraph generates one which is better,
since it doesn't correspond exactly to the highest value. For example
for a bar graph with the value 2,6,7,7,4,8,7 it would (might) go from
one to ten and then plot appropriate marks.

This is really what I want to achieve. But it should be able to
accommodate all sorts of values, from small to large.

-- 
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] Attributes vs. Accessors

2008-08-25 Thread Richard Heyes
 Curious. Which do you prefer and why?

Accessor methods. They allow for changes in the future that may well
be unforeseen at the moment. Or at least that would be my response
with PHP4. Now with the __get and __set built-in accessors, that's
pretty much taken care of.

 I access directly to avoid pointless method calls for reads.  It'd be
 nice if there were a way to define a public read-only mode,

Not tried this, but you may be able to do it with a __get method that
doesn't return anything.

-- 
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] concatenating with . or ,

2008-08-25 Thread Govinda

Good, understood.

To deepen (for me):

why does this:
echo 'p$_POST[\'SNGstep\']='.var_dump($_POST['SNGstep']).'^/p'.\n;
spit out:
NULL
p$_POST['SNGstep']=^/p

while this:
echo 'p$_POST[\'SNGstep\']=',var_dump($_POST['SNGstep']),'^/p'.\n;
spits out:
p$_POST['SNGstep']=NULL
^/p

?

I think it must be related to something Maciek was showing in his  
excellent example, but I am too green to see.



On Aug 25, 2008, at 7:48 AM, Thiago Melo de Paula wrote:


Govinda,

please, consider the following code:

?php
$brandA = 'Porshe';
$brandB = 'Jaguar';

$testA = $branA . $brandB; //testA will have the value PorsheJaguar

$testB = $branA , $brandB; //Returns a Parse error: syntax error,  
unexpected

',' in /test.php on line 7
?



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



[PHP] alphabetical filenames with readdir

2008-08-25 Thread Ed Curtis

Is there a way to make readdir output filenames alphabetically?

Thanks,

Ed


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



[PHP] Re: index.php not autoloading in apache

2008-08-25 Thread Vince Sabio

** At 13:03 +0200 on 08/25/2008, Carlos Medina wrote:

Vince Sabio schrieb:

I am running PHP v5.2.6 on an Apache v2.2 server. For some reason, 
Apache is not automatically loading index.php files, even when 
there is no other index.* file in the directory; it will throw a 
you do not have permission to access [directory] instead.


[..]


Hi Vince,
search (grep/find ) for DirectoryIndex: Statement


Many thanks to Carlos and Richard -- I added index.php to 
DirectoryIndex:, restarted Apache, and all is working fine now.


__
Vince Sabio  [EMAIL PROTECTED]

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



Re: [PHP] concatenating with . or ,

2008-08-25 Thread Stut

On 25 Aug 2008, at 16:09, Govinda wrote:

Good, understood.

To deepen (for me):

why does this:
echo 'p$_POST[\'SNGstep\']='.var_dump($_POST['SNGstep']).'^/ 
p'.\n;

spit out:
NULL
p$_POST['SNGstep']=^/p

while this:
echo 'p$_POST[\'SNGstep\']=',var_dump($_POST['SNGstep']),'^/ 
p'.\n;

spits out:
p$_POST['SNGstep']=NULL
^/p

?

I think it must be related to something Maciek was showing in his  
excellent example, but I am too green to see.


Oone is a concatenated string, the other is arguments. Arguments are  
executed and output in order, whereas the concatenation causes the  
function calls to be executed first and then the echo to display the  
return values concatenated into a single string.


Because var_dump *outputs* stuff rather than returning it, in the  
concatenation version the NULL outputs before the rest of the string.


Hope that clears it up.

-Stut

--
http://stut.net/


On Aug 25, 2008, at 7:48 AM, Thiago Melo de Paula wrote:


Govinda,

please, consider the following code:

?php
$brandA = 'Porshe';
$brandB = 'Jaguar';

$testA = $branA . $brandB; //testA will have the value PorsheJaguar

$testB = $branA , $brandB; //Returns a Parse error: syntax error,  
unexpected

',' in /test.php on line 7
?



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




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



Re: [PHP] concatenating with . or ,

2008-08-25 Thread Yeti
That is why i love this list. Always something new to learn.
What I am still wondering about is if it is faster to use commas or
the {} brackets? ( I don't know how that technique is called, since
I'm not a walking dictionary)

Example:

$var = blah blah;
echo $var,test;
echo {$var}test;

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



Re: [PHP] alphabetical filenames with readdir

2008-08-25 Thread Ed Curtis

Ed Curtis wrote:

Is there a way to make readdir output filenames alphabetically?

Thanks,

Ed



Never mind. I figured out how to do it using an array and sort.

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



Re: [PHP] concatenating with . or ,

2008-08-25 Thread Robert Cummings
On Mon, 2008-08-25 at 17:34 +0200, Yeti wrote:
 That is why i love this list. Always something new to learn.
 What I am still wondering about is if it is faster to use commas or
 the {} brackets? ( I don't know how that technique is called, since
 I'm not a walking dictionary)

Here is the order of speed from fastest to slowest:

commas  - only useful if using echo or print
.   - concatenation
{$foo}- interpolation of variables via double quotes
 - heredoc

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Attributes vs. Accessors

2008-08-25 Thread Eric Butera
On Mon, Aug 25, 2008 at 11:01 AM, Richard Heyes [EMAIL PROTECTED] wrote:
 Curious. Which do you prefer and why?

 Accessor methods. They allow for changes in the future that may well
 be unforeseen at the moment. Or at least that would be my response
 with PHP4. Now with the __get and __set built-in accessors, that's
 pretty much taken care of.

 I access directly to avoid pointless method calls for reads.  It'd be
 nice if there were a way to define a public read-only mode,

 Not tried this, but you may be able to do it with a __get method that
 doesn't return anything.

 --
 Richard Heyes
 http://www.phpguru.org


Oh it'd be possible, but all this does is distract me from the purpose
of my code.  I am easily distracted though seeing as I'm writing this
out in the first place!  :)  A simple note in the docs saying this is
read only is enough for me.  You'd have to put a note in there about
how it will throw an exception upon write anyways.  *shrug*  But again
these are very specific pieces of code that are getting public
properties.

This goes in line with all the other coding practices I try to use.
Registry over singleton, notification queue over direct observer, etc.
 Let something else do the heavy lifting when possible.


class readonlytest {

private $readonly = array('meh');
private $meh = 'meh value';
public $blah;

private function __get($name) {
if (in_array($name, $this-readonly)) {
return $this-{$name};
}
}

private function __set($name, $value) {
if (in_array($name, $this-readonly)) {
throw new Exception(The property {$name} is read 
only);
}
$this-{$name} = $value;
}

}

$test = new readonlytest;

echo Pre-blah:;
var_dump($test-blah);
$test-blah = 'blah';
echo Post-blah:;
var_dump($test-blah);

echo Reading meh:;
var_dump($test-meh);
try {
$test-meh = 'meh';
} catch (Exception $e) {
echo Exception:;
var_dump($e);
}
var_dump($test-meh);

But why would I want to clutter up my class with that nonsense?

Output:

Pre-blah:
null
Post-blah:
string 'blah' (length=4)
Reading meh:
string 'meh value' (length=9)
Exception:
object(Exception)[2]
  protected 'message' = string 'The property meh is only' (length=24)
  private 'string' = string '' (length=0)
  protected 'code' = int 0
  protected 'file' = string '/Users/eric/Sites/blah.php' (length=26)
  protected 'line' = int 18
  private 'trace' =
array
  0 =
array
  'file' = string '/Users/eric/Sites/blah.php' (length=26)
  'line' = int 36
  'function' = string '__set' (length=5)
  'class' = string 'readonlytest' (length=12)
  'type' = string '-' (length=2)
  'args' =
array
  0 = string 'meh' (length=3)
  1 = string 'meh' (length=3)
string 'meh value' (length=9)

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



[PHP] APC vs. eaccelerator?

2008-08-25 Thread David Park
Hi All,

I currently run a phpBB site using phpBB v. 2.0.22 and PHP4.  We'd like to
install either APC or eaccelerator to speed up the site's performance.  I'm
not sure whether we should choose APC or eaccelerator since I'm a newbie to
PHP caching.

Which do you think is better - APC or eacclerator?  Here are some criteria
that I'd like to use in evaluating APC vs. eacclerator: 1) compatibility, 2)
stability and 3) speed.

Some older posts on the net (from 2006) complained about incompatibilities
between APC/eacclerator and phpBB and about crashes of APC/eacclerator.  I'm
hoping that these problems have been cleared up by now.

Thanks for your help!

David


Re: [PHP] alphabetical filenames with readdir

2008-08-25 Thread tedd

At 10:45 AM -0400 8/25/08, Ed Curtis wrote:

Is there a way to make readdir output filenames alphabetically?

Thanks,

Ed


Sure -- put the results in an array and then sort() or natsort() it.

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] Auto-generating a graphs Y scale

2008-08-25 Thread tedd

At 3:52 PM +0100 8/25/08, Richard Heyes wrote:

  First, the y scale is the one that runs up and down and not right to left.

  :-)



Yes I know.


 Second, the physical length of the y scale should be static and whatever you
 want it to be (i.e., 5 inches, 10 inches, etc.).


That gives a poor range IMO. JPGraph generates one which is better,
since it doesn't correspond exactly to the highest value. For example
for a bar graph with the value 2,6,7,7,4,8,7 it would (might) go from
one to ten and then plot appropriate marks.

This is really what I want to achieve. But it should be able to
accommodate all sorts of values, from small to large.

--
Richard Heyes



Richard:

There's no poor, nor good, range for that.

If it was me I might take the maximum x and y coordinates and use 
values that are 10 percent larger for the axis. The goodness or 
poorness depends upon the data and how well that data is shown for 
evaluation.


The point is that the way to create a graph is to figure out the 
maximum values, determined from the points, and then create axis to 
show that.


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] concatenating with . or ,

2008-08-25 Thread tedd

At 5:34 PM +0200 8/25/08, Yeti wrote:

That is why i love this list. Always something new to learn.
What I am still wondering about is if it is faster to use commas or
the {} brackets? ( I don't know how that technique is called, since
I'm not a walking dictionary)

Example:

$var = blah blah;
echo $var,test;
echo {$var}test;


One of the other things about this list is that sometimes people 
actually test their ideas.


It's not that big of a deal to set up a test to show which is faster. 
So, if you would like to know, then write a test for it.


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



[PHP] Re: APC vs. eaccelerator?

2008-08-25 Thread Colin Guthrie

David Park wrote:

Hi All,

I currently run a phpBB site using phpBB v. 2.0.22 and PHP4.  We'd like to
install either APC or eaccelerator to speed up the site's performance.  I'm
not sure whether we should choose APC or eaccelerator since I'm a newbie to
PHP caching.

Which do you think is better - APC or eacclerator?  Here are some criteria
that I'd like to use in evaluating APC vs. eacclerator: 1) compatibility, 2)
stability and 3) speed.

Some older posts on the net (from 2006) complained about incompatibilities
between APC/eacclerator and phpBB and about crashes of APC/eacclerator.  I'm
hoping that these problems have been cleared up by now.


I'm a pretty happy APC user right now.

Amoung other things, I do run a not-overly-busy phpBB site under it and 
I've not had any complaints.


For me APC was just a drop in task and while I did keep a careful look 
out for any issues, it was all rather painless. I went for APC due to 
the fact that there were some interesting Summer of Code projects 
proposed that should allow for even more interesting stuff in the future :)


Also APC has an extension that you can turn on that gets the status of 
file uploads, so if you operate a site where users can upload large 
files, this is a nice feature for interactive displays.


Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



Re: [PHP] APC vs. eaccelerator?

2008-08-25 Thread mike
On 8/25/08, David Park [EMAIL PROTECTED] wrote:

 Some older posts on the net (from 2006) complained about incompatibilities
 between APC/eacclerator and phpBB and about crashes of APC/eacclerator.  I'm
 hoping that these problems have been cleared up by now.

2006 is a century ago in open source time :P

i was using turck mmcache which turned into eaccelerator for a while.
i also tried xcache. however, i switched to APC over a year ago now.
it's maintained by core php developers, so i figure it's the best as
it would receive little perks due to new features/fixes being put in
to the core php code and the developers implementing them working on
APC.

i have never done any benchmarks or anything, but i'm pretty sure
they're all relatively close speed-wise. stability-wise i've never had
an issue with APC..

the file upload stuff would be cool except i need something that
supports multiple webservers, not shared memory on a specific host.

besides, i think i've heard PHP6 will have a built in byte-code cache
already, and i am sure it will use APC/portions of APC (why not, it's
already there)

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



Re: [PHP] APC vs. eaccelerator?

2008-08-25 Thread Robert Cummings
On Mon, 2008-08-25 at 10:24 -0700, David Park wrote:
 Hi All,
 
 I currently run a phpBB site using phpBB v. 2.0.22 and PHP4.  We'd like to
 install either APC or eaccelerator to speed up the site's performance.  I'm
 not sure whether we should choose APC or eaccelerator since I'm a newbie to
 PHP caching.
 
 Which do you think is better - APC or eacclerator?  Here are some criteria
 that I'd like to use in evaluating APC vs. eacclerator: 1) compatibility, 2)
 stability and 3) speed.
 
 Some older posts on the net (from 2006) complained about incompatibilities
 between APC/eacclerator and phpBB and about crashes of APC/eacclerator.  I'm
 hoping that these problems have been cleared up by now.

Many years ago now I was using PHPAccelerator... when it stopped being
updated I made the switch. At that time I checked out both APC and
eaccelerator and found eaccelerator to be the faster for my needs.
Recently, and I don't recall the link, I read something that indicated
eaccelerator is faster than APC. Mileage may vary though depending on
individual usage patterns. Either way, I'd say they are probably fairly
interchangeable.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



[PHP] Re: APC vs. eaccelerator?

2008-08-25 Thread Colin Guthrie

mike wrote:

besides, i think i've heard PHP6 will have a built in byte-code cache
already, and i am sure it will use APC/portions of APC (why not, it's
already there)



Oh yeah, that was another reason I went for APC... forgot about that one :)

Col


--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



Re: [PHP] Re: APC vs. eaccelerator?

2008-08-25 Thread Nathan Nobbe
On Mon, Aug 25, 2008 at 12:23 PM, Colin Guthrie [EMAIL PROTECTED]wrote:

 mike wrote:

 besides, i think i've heard PHP6 will have a built in byte-code cache
 already, and i am sure it will use APC/portions of APC (why not, it's
 already there)



 Oh yeah, that was another reason I went for APC... forgot about that one :)


yea; apc is supposed to be bundled w php6 (thats what i hrd from one of the
apc devs when i was in dc).

-nathan


Re: [PHP] APC vs. eaccelerator?

2008-08-25 Thread Nathan Nobbe
On Mon, Aug 25, 2008 at 12:02 PM, Robert Cummings [EMAIL PROTECTED]wrote:

 On Mon, 2008-08-25 at 10:24 -0700, David Park wrote:
  Hi All,
 
  I currently run a phpBB site using phpBB v. 2.0.22 and PHP4.  We'd like
 to
  install either APC or eaccelerator to speed up the site's performance.
  I'm
  not sure whether we should choose APC or eaccelerator since I'm a newbie
 to
  PHP caching.
 
  Which do you think is better - APC or eacclerator?  Here are some
 criteria
  that I'd like to use in evaluating APC vs. eacclerator: 1) compatibility,
 2)
  stability and 3) speed.
 
  Some older posts on the net (from 2006) complained about
 incompatibilities
  between APC/eacclerator and phpBB and about crashes of APC/eacclerator.
  I'm
  hoping that these problems have been cleared up by now.

 Many years ago now I was using PHPAccelerator... when it stopped being
 updated I made the switch. At that time I checked out both APC and
 eaccelerator and found eaccelerator to be the faster for my needs.
 Recently, and I don't recall the link, I read something that indicated
 eaccelerator is faster than APC. Mileage may vary though depending on
 individual usage patterns. Either way, I'd say they are probably fairly
 interchangeable.


i think i read this recently too, because we use eac at work (i was scoping
it out).  ive used only apc in that past myself.  after reading around a
little a couple of weeks back, and poking around in the eac source, it looks
like eac is pretty feature rich, and possibly faster at this point.
however, i suspect, with the growing popularity of apc, the tide will turn
at some point and apc will be the best opcode caching solution.

-nathan


Re: [PHP] newbie OT Eudora

2008-08-25 Thread tedd

At 8:47 AM -0500 8/25/08, Philip Thompson wrote:
Apple Mail. It's by far the best email app I've seen/used. =D You 
can hide/view headers as desired.


~Philip



Philip:

Of course, I have Apple's Mail and have used it, but I still like 
Eudora. However, I think I see the writing on the wall.


I'll look at Apple's Mail again, but I would like to keep all my 
emails (1995 to present) as Eudora does.


Eudora is actually my word processor of choice now.

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] newbie OT Eudora

2008-08-25 Thread tedd

At 9:53 AM -0400 8/25/08, Wolf wrote:
Really, they still make Eudora?  Or is this an old copy on the 
MacIntosh IIe that you are running.  ;)


Wolf


Wolf:

Yes, Eudora is still around, but it's open source now. However, I 
haven't received/heard of an update in a long time. The critter is 
dated, but still works great.


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



[PHP] comments function being spammed, how do I stop it?

2008-08-25 Thread Barnaby Walters


Hi there!

my comments function for my website (at www.waterpigs.co.uk/php/ 
phpTest.php) is being spammed, what would be your sugguestions of a  
way to deal with it?  I was thinking of something to do with  
searching the strings of comments contained in the database for rude  
words, etc, but I'm unsure as to how to  do it.


Any help would be appreciated greatly.

Thanks,
Barnaby
_
www.waterpigs.co.uk
[EMAIL PROTECTED]





Re: [PHP] concatenating with . or ,

2008-08-25 Thread Bernhard Kohl
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml;
head
meta http-equiv=Content-Type content=text/html; charset=utf-8 /
titleTest for Tedd/title
/head
body
?php

# Ok tedd, if you insist ..

$iterations = 2;
$test_string = md5('test'); // a 32 character string
$test_array = array();
for ($i = 0; $i  $iterations; ++$i) $test_array[] = str_shuffle($test_string);
# - Comma
ob_start();
$s_t = microtime(true);
foreach ($test_array as $array_value) {
echo $test_string, $array_value;
}
$e_t = microtime(true);
ob_end_clean();
echo 'pComma took: strong'.(abs($e_t -
$s_t)*1000/$iterations).'/strong milliseconds on average./p';
# -- Concatenation
ob_start();
$s_t = microtime(true);
foreach ($test_array as $array_value) {
echo $test_string.$array_value;
}
$e_t = microtime(true);
ob_end_clean();
echo 'pConcatenation: strong'.(abs($e_t -
$s_t)*1000/$iterations).'/strong milliseconds on average./p';
# -- Interpolation
ob_start();
$s_t = microtime(true);
foreach ($test_array as $array_value) {
echo {$test_string}{$array_value};
}
$e_t = microtime(true);
ob_end_clean();
echo 'pInterpolation: strong'.(abs($e_t -
$s_t)*1000/$iterations).'/strong milliseconds on average./p';
# -- HereDoc
ob_start();
$s_t = microtime(true);
foreach ($test_array as $array_value) {
   echo TEST
$test_string$array_value
TEST;
}
$e_t = microtime(true);
ob_end_clean();
echo 'pHeredoc: strong'.(abs($e_t -
$s_t)*1000/$iterations).'/strong milliseconds on average./p';
/*
I usually get results similar to these ones:

Comma took: 0.0191585 milliseconds on average.
Concatenation: 0.0195376 milliseconds on average.
Interpolation: 0.0279227 milliseconds on average.
Heredoc: 0.0247411 milliseconds on average.

*/
?
/body
/html

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



Re: [PHP] comments function being spammed, how do I stop it?

2008-08-25 Thread Thiago H. Pojda
Captcha?

On 8/25/08, Barnaby Walters [EMAIL PROTECTED] wrote:


 Hi there!

 my comments function for my website (at www.waterpigs.co.uk/php/phpTest.php)
 is being spammed, what would be your sugguestions of a way to deal with it?
  I was thinking of something to do with searching the strings of comments
 contained in the database for rude words, etc, but I'm unsure as to how to
  do it.

 Any help would be appreciated greatly.

 Thanks,
 Barnaby
 _
 www.waterpigs.co.uk
 [EMAIL PROTECTED]






-- 
Thiago Henrique Pojda


Re: [PHP] comments function being spammed, how do I stop it?

2008-08-25 Thread David Otton
2008/8/25 Barnaby Walters [EMAIL PROTECTED]:

 my comments function for my website (at www.waterpigs.co.uk/php/phpTest.php)
 is being spammed, what would be your sugguestions of a way to deal with it?
  I was thinking of something to do with searching the strings of comments
 contained in the database for rude words, etc, but I'm unsure as to how to
  do it.

Akismet. One of the classes for interfacing with it is here:

http://www.achingbrain.net/stuff/php/akismet

-- 

http://www.otton.org/

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



Re: [PHP] comments function being spammed, how do I stop it?

2008-08-25 Thread Jim Lucas

Barnaby Walters wrote:


Hi there!

my comments function for my website (at 
www.waterpigs.co.uk/php/phpTest.php) is being spammed, what would be 
your sugguestions of a way to deal with it?  I was thinking of something 
to do with searching the strings of comments contained in the database 
for rude words, etc, but I'm unsure as to how to  do it.


Any help would be appreciated greatly.

Thanks,
Barnaby
_
www.waterpigs.co.uk
[EMAIL PROTECTED]






Here is the function that I added to a generic guest book script.  It works 
great for me.  I have a predefined list of sexual, pharmaceutical, rude, 
vulgar, etc... words that I have in the spamwords.dat file.


function is_spam($str) {
  $data = './data/spamwords.dat';
  $spamword = file($data);
  $str = strtolower($str);
  foreach ($spamword AS $word) {
$word = trim($word);
if ( ! empty($word)  // Blank line
 strpos($word, 0, 1) != '#'  // Comment line
 strpos($str, strtolower($word)) !== false ) { // Compare
  return true;
}
  }
  return false;
}

Just setup the spamwords.dat file to have each word/string that you want to 
reject for separated on each line.


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



[PHP] Remote File download is very slow

2008-08-25 Thread Shiplu
Hello folks,
I have written a method to download file from remote server. normally those
fill will be huge in size. from 1MB to 400MB.
I am using fsockopen and curl to download the file.
But the problem is its too slow.
Very very slow.
The code can be found on http://nopaste.info/55817730b3.html
I just put the method body.

Can any one help me on increasing the speed?

Thanks in Advance
--
http://talk.cmyweb.net/
http://twitter.com/shiplu


[PHP] Re: Remote File download is very slow

2008-08-25 Thread Shiplu
Okay, I attached the code. Not everyone will click the paste bin link. :P

the code is a downloading function of a class.
the class has some methods need to be explained.
1) $this-debugMessage, it sends message to a call back function to a caller

2) $this-doCallback, sends the amount of bytes read to a call back function
to the caller\
3) $this-localfilename is the file where the remote file will be downloaded

4) $this-lfp is localfilepointer
5) read_chunk_size = 512
6) $headers is a predefined array of headers
7) $postdata is the url encoded data to send by post method.

Here is the code
_
$this-lfp = fopen($this-localfilename,wb);

if($this-lfp===false){return false;}

if(function_exists('fsockopen')){
  $pu = parse_url($this-download_url);
  $request=POST {$pu['path']} HTTP/1.1\r\n;
  $request.=Host: {$pu['host']}\r\n;
  $request.=Content-type:
application/x-www-form-urlencoded\r\n;
  $request.=implode(\r\n,$headers).\r\n;
  $request.=Connection: close\r\n;
  $request.=Content-length: .strlen($postdata).\r\n\r\n;


  $sock = fsockopen($pu['host'],80,$errno,$errstr);

  fwrite($sock,$request);

  $this-debugMessage(Headers Sent\r\n.$request);

  fwrite($sock,$postdata);

  $headers=;
  do{
$headers.=fread($sock,128);
  }while(strpos($headers,\r\n\r\n)===false);

  $pos = strpos($headers,\r\n\r\n);
  $headers = split(\r\n\r\n,$headers);
  $headers = $headers[0];

  $this-debugMessage(Headers recieved.$headers.\r\n);
  $this-debugMessage(Downloading started. . .\r\n);
  $content = substr($headers,$pos+4);
  if($content!==false){
$this-doCallback(fwrite($this-lfp,$content));
  }
  while(!feof($sock)){

$this-doCallback(fwrite($this-lfp,fread($sock,$this-read_chunk_size)));

  }
  $this-debugMessage(Download finished\r\n);

  fclose($sock);

}else {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,$this-download_url);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  if(!empty($this-cookiefile)){
curl_setopt($ch, CURLOPT_COOKIEFILE,
$this-cookiefile);
curl_setopt($ch, CURLOPT_COOKIEJAR,
$this-cookiefile);
  }
  curl_setopt($ch,CURLOPT_FILE,$this-lfp);
  curl_setopt($ch, CURLOPT_POST,1);
  curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata);

  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

  curl_exec($ch);
  curl_close($ch);
}
fclose($this-lfp);
_

-- 
Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu


Re: [PHP] Remote File download is very slow

2008-08-25 Thread David Otton
2008/8/25 Shiplu [EMAIL PROTECTED]:
 Hello folks,
 I have written a method to download file from remote server. normally those
 fill will be huge in size. from 1MB to 400MB.
 I am using fsockopen and curl to download the file.

 But the problem is its too slow.
 Very very slow.

What happens when you remove the first half of the if(), the bit that
relies on fsockopen(), and only use curl?

-- 

http://www.otton.org/

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



Re: [PHP] Remote File download is very slow

2008-08-25 Thread Shiplu
Nothing works.
I was using curl actually.
It was hell slow.
Then I added the fsockeopen option.
Its slwo too.
now I am thinking to add socket_* functions.
But If dont know what is the problem how can I resolve it.
change scheme may not solve it. :(

-- 
Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu


Re: [PHP] Remote File download is very slow

2008-08-25 Thread David Otton
2008/8/25 Shiplu [EMAIL PROTECTED]:
 Nothing works.
 I was using curl actually.
 It was hell slow.
 Then I added the fsockeopen option.
 Its slwo too.
 now I am thinking to add socket_* functions.
 But If dont know what is the problem how can I resolve it.
 change scheme may not solve it. :(

Ok, lets start by getting some accurate data.

Here's a script that downloads a 6Mb MP3:

?php

$fp = fopen( temp1.mp3, wb );
$ch = curl_init();

curl_setopt( $ch, CURLOPT_URL, http://gramotunes.com/Life_is_Long.mp3; );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt( $ch, CURLOPT_FILE, $fp );

curl_exec( $ch );

curl_close( $ch );

Save it as download.php, and run the following two commands:

time php download.php
time wget http://gramotunes.com/Life_is_Long.mp3

I get

real0m6.105s

and

real0m5.927s

If your results are about equal, then the problem is not with PHP.

-- 

http://www.otton.org/

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



Re: [PHP] FW: [SPAM] [PHP] FIFO files on PHP?

2008-08-25 Thread Waynn Lue
On Wed, Jul 2, 2008 at 1:22 AM, Chris Scott [EMAIL PROTECTED] wrote:

  -Original Message-
  From: Waynn Lue [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, July 01, 2008 11:06 PM
  To: php-general@lists.php.net
  Subject: [SPAM] [PHP] FIFO files on PHP?
  Importance: Low
 
  I'm trying to build a queue out using FIFO files (someone on the MySQL
  list suggested checking them out instead of using the database), but
  I'm running into a problem because of the synchronous fwrite call.
  Here's the code:
 
$fifoFile = '/tmp/fifo';
if (!file_exists($fifoFile)) {
  posix_mkfifo($fifoFile, 0600);
}
$fp = fopen($fifoFile, w);
fwrite($fp, content);
fclose($fp);
 
  But this will block until something actually reads the pipe.  Is there
  any way to write to the pipe, then go away as opposed to waiting until
  something consumes it?  Otherwise, I may just go back to a database
  table.
 
  Thanks,
  Waynn
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php

 Fifo nodes are equivalent to a pipe (|) and have no size on the file
 system and therefore the write won't finish until some process reads
 from the node. See the man page http://linux.die.net/man/7/fifo .

Wow, my mail client filtered these responses so I only just noticed them--I
thought there were no responses.  Thanks for letting me know, I ended up
using threads to accomplish something similar.


Re: [PHP] Remote File download is very slow

2008-08-25 Thread Shiplu
They take same time.
let me tell you how my code works.
it download a file and in the same time it reports a progress by a call back
function.
this script is called from web. not console. it provides live debug
messages.
I'll give you a time wise debug log.

-- 
Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu


Re: [PHP] Remote File download is very slow

2008-08-25 Thread Shiplu
here are the log messages. see the timinings.

[2008-08-25 18:09:05.21780900]started downloading in
Live_In_Cuba_-_Louder_Than_War.part1.rar
[2008-08-25 18:09:05.60409200]Headers Sent
POST /files/108041147/1693469/Live_In_Cuba_-_Louder_Than_War.part1.rar HTTP/1.1
Host: rs246tl3.rapidshare.com
Content-type: application/x-www-form-urlencoded
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16
Accept: 
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-language: en-us,en;q=0.7,bn;q=0.3
Accept-charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: close
Content-length: 9
[2008-08-25 18:09:06.06572600]Headers recievedHTTP/1.1 200 OK
Date: Tue, 26 Aug 2008 00:09:05 GMT
Connection: close
Content-Type: application/octet-stream
Accept-Ranges: bytes
Content-Disposition: Attachment;
filename=Live_In_Cuba_-_Louder_Than_War.part1.rar
Content-Length: 104857600
[2008-08-25 18:09:06.06588900]Downloading started. . .
[2008-08-25 18:09:11.35468500]Downloaded 262144 bytes
[2008-08-25 18:09:15.26531200]Downloaded 524288 bytes
[2008-08-25 18:09:20.83112600]Downloaded 786432 bytes
[2008-08-25 18:09:26.26205800]Downloaded 1048576 bytes
[2008-08-25 18:09:31.78788500]Downloaded 1310720 bytes
[2008-08-25 18:09:37.27102800]Downloaded 1572864 bytes
[2008-08-25 18:09:42.72577600]Downloaded 1835008 bytes
[2008-08-25 18:09:48.08036500]Downloaded 2097152 bytes
[2008-08-25 18:09:53.46441000]Downloaded 2359296 bytes
[2008-08-25 18:09:58.91484500]Downloaded 2621440 bytes
[2008-08-25 18:10:04.42331800]Downloaded 2883584 bytes
[2008-08-25 18:10:10.00015700]Downloaded 3145728 bytes
[2008-08-25 18:10:15.30924700]Downloaded 3407872 bytes


see the speed?? Its too slow.


-- 
Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu