Re: [PHP] Re: Quickly verifying single word.

2008-06-04 Thread Per Jessen
Shawn McKenzie wrote:

>> if (preg_match('/[\s]*/', $string) === false) {
>> echo 'No spaces!';
>> }
>> 
>> -Shawn
> 
> Second one doesn't work for some reason.  No time now to test, will
> later.

How about:

if (preg_match('/\s/', $string) === false) {
echo 'No spaces!';
}


/Per Jessen, Zürich


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



Re: [PHP] Regex in PHP

2008-06-04 Thread Robert Cummings
On Thu, 2008-06-05 at 00:24 -0400, Nathan Nobbe wrote:
>
> you really know how to rub it in there rob.  but i was looking at the
> implementation in the php code, looks like somebody likes my idea
> (this code
> found in ext/standard/string.c).  on the second line the haystack is
> converted to lower case[1], then if it passes a couple of checks, the
> needle
> is converted to lower case[2], and lastly the comparison is
> performed[3].
> there is no logic to check both cases.
> (i have placed a star beside the statements ive referred to).
> ...
> haystack_dup = estrndup(haystack, haystack_len);
> *[1]php_strtolower(haystack_dup, haystack_len);
> 
> if (Z_TYPE_P(needle) == IS_STRING) {
> if (Z_STRLEN_P(needle) == 0 || Z_STRLEN_P(needle) >
> haystack_len) {
> efree(haystack_dup);
> RETURN_FALSE;
> }
> 
> needle_dup = estrndup(Z_STRVAL_P(needle), Z_STRLEN_P(needle));
> *[2]php_strtolower(needle_dup, Z_STRLEN_P(needle));
> *[3]found = php_memnstr(haystack_dup + offset, needle_dup,
> Z_STRLEN_P(needle), haystack_dup + haystack_len);
> }

Funny, I guess they took the quick route. This code could obviously be
optmized :)

But let's go with something used more often... such as more traditional
string comparison where you're more likely to want to eke out
efficiency:

ZEND_API int zend_binary_strcasecmp(char *s1, uint len1, char *s2, uint
len2)
{
int len;
int c1, c2;

len = MIN(len1, len2);

while (len--) {
c1 = zend_tolower((int)*(unsigned char *)s1++);
c2 = zend_tolower((int)*(unsigned char *)s2++);
if (c1 != c2) {
return c1 - c2;
}
}

return len1 - len2;
}

Well looks like they do indeed do a conversion.. but on a char by char
basis. Strange that. Could more than likely speed it up by doing an
initial exactness comparison and then falling back on the above. Maybe
I'll compile and test out the following later:

ZEND_API int zend_binary_strcasecmp
(char *s1, uint len1, char *s2, uint len2)
{
int len;
int c1, c2;

len = MIN(len1, len2);

while (len--) {
c1 = (int)*(unsigned char *)s1++;
c2 = (int)*(unsigned char *)s2++;

if( c1 != c2 ){
c1 = zend_tolower( c1 );
c2 = zend_tolower( c2 );

if (c1 != c2) {
return c1 - c2;
}
}
}

return len1 - len2;
}

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] Regex in PHP

2008-06-04 Thread Nathan Nobbe
On Wed, Jun 4, 2008 at 11:43 PM, Robert Cummings <[EMAIL PROTECTED]>
wrote:

> On Wed, 2008-06-04 at 23:20 -0400, Nathan Nobbe wrote:
> >
> > i repeated your test using the time program and splitting the script into
> 2,
> > one for each strpos and stripos, to find similar results.  imo, there is
> no
> > need for 2 comparisons for case-insensitive searches, because both
> arguments
> > can be converted to a single case prior to the search.  obviously, there
> is
> > a small amount of overhead there the case-sensitive search is
> unencumbered
> > by.  i guess i never sat down and thought about how that algorithm would
> > work (case-sensitive) =/.
> >
> > thanks for the tips rob.  sorry to bother you richard.
>
> You would do two comparisons... why incur the overhead of a conversion
> if one is not necessary.


because it simplifies the algorithm, there is no need for conditional logic.


> First you do case sensitive match, if that
> fails then you try the alternative version comparison. It is inefficient
> to perform 2 conversions and a single comparison in contrast.


3 operations vs. 1 or potentially 2, sure.


> Similarly,
> it's very inefficient to convert two entire strings then perform a
> comparison.


then they could be converted one at a time as the strings were traversed to
increase efficiency.


> If the first characters differ then conversion of the rest
> of the strings was pointless.


good point.


> This is basic algorithms in computer
> science.
>

you really know how to rub it in there rob.  but i was looking at the
implementation in the php code, looks like somebody likes my idea (this code
found in ext/standard/string.c).  on the second line the haystack is
converted to lower case[1], then if it passes a couple of checks, the needle
is converted to lower case[2], and lastly the comparison is performed[3].
there is no logic to check both cases.
(i have placed a star beside the statements ive referred to).
...
haystack_dup = estrndup(haystack, haystack_len);
*[1]php_strtolower(haystack_dup, haystack_len);

if (Z_TYPE_P(needle) == IS_STRING) {
if (Z_STRLEN_P(needle) == 0 || Z_STRLEN_P(needle) > haystack_len) {
efree(haystack_dup);
RETURN_FALSE;
}

needle_dup = estrndup(Z_STRVAL_P(needle), Z_STRLEN_P(needle));
*[2]php_strtolower(needle_dup, Z_STRLEN_P(needle));
*[3]found = php_memnstr(haystack_dup + offset, needle_dup,
Z_STRLEN_P(needle), haystack_dup + haystack_len);
}
...

-nathan


Re: [PHP] Regex in PHP

2008-06-04 Thread Robert Cummings
On Wed, 2008-06-04 at 23:20 -0400, Nathan Nobbe wrote:
>
> i repeated your test using the time program and splitting the script into 2,
> one for each strpos and stripos, to find similar results.  imo, there is no
> need for 2 comparisons for case-insensitive searches, because both arguments
> can be converted to a single case prior to the search.  obviously, there is
> a small amount of overhead there the case-sensitive search is unencumbered
> by.  i guess i never sat down and thought about how that algorithm would
> work (case-sensitive) =/.
> 
> thanks for the tips rob.  sorry to bother you richard.

You would do two comparisons... why incur the overhead of a conversion
if one is not necessary. First you do case sensitive match, if that
fails then you try the alternative version comparison. It is inefficient
to perform 2 conversions and a single comparison in contrast. Similarly,
it's very inefficient to convert two entire strings then perform a
comparison. If the first characters differ then conversion of the rest
of the strings was pointless. This is basic algorithms in computer
science.

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] Regex in PHP

2008-06-04 Thread Nathan Nobbe
On Wed, Jun 4, 2008 at 2:06 PM, Robert Cummings <[EMAIL PROTECTED]>
wrote:

> On Wed, 2008-06-04 at 11:18 -0600, Nathan Nobbe wrote:
> > On Wed, Jun 4, 2008 at 11:12 AM, Robert Cummings <[EMAIL PROTECTED]>
> > wrote:
> >
> > > Did you just try to use a test that used a single iteration to prove me
> > > wrong? OMFG ponies!!! Loop each one of those 10 million times, use a
> > > separate script for each, and use the system time program to
> > > appropriately measure the time the system takes.
> >
> >
> >  >
> > $str = 'asSAFAASFDADSfasfjhalskfjhlaseAERQWERQWER;.dafasjhflasfjd';
> > $search = 'fdasASDFAafdas';
> >
> > $start = microtime();
> >
> > for($i = 0; $i < 1000; $i++)
> > strpos($str, $search);
> >
> > $end = microtime();
> > $r1 = $end - $start;
> >
> > $start = microtime();
> >
> > for($i = 0; $i < 1000; $i++)
> > stripos($str, $search);
> >
> > $end2 = microtime();
> > $r2 = $end2 - $start;
> >
> > echo "strpos: $r1\n";
> > echo "stripos: $r2\n";
> >
> > if($r2 < $r1) {
> > echo 'stripos is faster' . PHP_EOL;
> > }
> > --
> > strpos: 0.730519
> > stripos: -0.098887
> > stripos is faster
>
> Negative time eh!? You're code must be buggy :| The time program works
> like this unde rmost nix systems:
>
>time php -q foo.php
>
> And then it returns a report of how much time was taken for various
> types of time. I've already sent an email with the appropriate timing of
> both versions. BTW, as primtive as microtime() is for this kind of
> measurement... you might want to read the manual to use it properly:
>
>http://ca3.php.net/manual/en/function.microtime.php
>
> You probably want:
>
>microtime( true )
>
> > stripos still dominates ;)  what is this system time program you speak of
> ?
> > and, ill put them into separate programs when i get home this evening,
> and
> > have more time to screw around.
>
> It's a simple thought process to understand that unless someone coding
> the PHP internals buggered their code, that stripos() cannot possibly be
> faster than strpos(). I really don't need benchmarks for something this
> simple to know which SHOULD be faster.
>

i repeated your test using the time program and splitting the script into 2,
one for each strpos and stripos, to find similar results.  imo, there is no
need for 2 comparisons for case-insensitive searches, because both arguments
can be converted to a single case prior to the search.  obviously, there is
a small amount of overhead there the case-sensitive search is unencumbered
by.  i guess i never sat down and thought about how that algorithm would
work (case-sensitive) =/.

thanks for the tips rob.  sorry to bother you richard.

-nathan


[PHP] Re: Quickly verifying single word.

2008-06-04 Thread Shawn McKenzie

Shawn McKenzie wrote:

Tyson Vanover wrote:
I need a quick way to make sure that a string is a single word with no 
white spaces.  I would prefer that it is a command that could fit on a 
single line.  Or at least an if block.


I have a few thoughts on this but it involves things like explode(), 
stripslashes(), etc.


if (strpos($string, ' ') === false) {
//may not work for tabs, newlines etc
echo 'No spaces!';
}


if (preg_match('/[\s]*/', $string) === false) {
echo 'No spaces!';
}

-Shawn


Second one doesn't work for some reason.  No time now to test, will later.

-Shawn

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



[PHP] Re: Quickly verifying single word.

2008-06-04 Thread Shawn McKenzie

Tyson Vanover wrote:
I need a quick way to make sure that a string is a single word with no 
white spaces.  I would prefer that it is a command that could fit on a 
single line.  Or at least an if block.


I have a few thoughts on this but it involves things like explode(), 
stripslashes(), etc.


if (strpos($string, ' ') === false) {
//may not work for tabs, newlines etc
echo 'No spaces!';
}


if (preg_match('/[\s]*/', $string) === false) {
echo 'No spaces!';
}

-Shawn

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



Re: [PHP] Objects and Traversing

2008-06-04 Thread Jim Lucas

VamVan wrote:

Hello Guys,

Here is the object. How can I get access to the [Name] = access. People who
help me with this can you please tell me what is the logic behind traversing
the objects and how do you gather the values. Thanks. I am looking for an
answer like this $queryResult->f->dsfsdf

QueryResult Object
(
[queryLocator] =>
[done] => 1
[records] => Array
(
[0] => SObject Object
(
[type] => Contact
[fields] =>
[sobjects] => Array
(
[0] => SObject Object
(
[type] => Account
[fields] => SimpleXMLElement Object
(
[Name] => Access
)

)

)

)

)

[size] => 1
)




Simply this would give you name
$QueryResult->records[0]->sobjects[0]->fields->Name


--
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



Re: [PHP] Quickly verifying single word.

2008-06-04 Thread Ted Wood



There's probably a regex solution that is most elegant, but here is  
one solution:


if ($str == str_replace(array(' ', "\n"), '', $str)) {

// if you get here, then $str has no spaces or newline characters

}

~Ted



On 4-Jun-08, at 4:04 PM, Tyson Vanover wrote:

I need a quick way to make sure that a string is a single word with  
no white spaces.  I would prefer that it is a command that could fit  
on a single line.  Or at least an if block.


I have a few thoughts on this but it involves things like explode(),  
stripslashes(), etc.


--
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] Objects and Traversing

2008-06-04 Thread Ted Wood


You should be able to access the "Name" field using this syntax:

QueryResult->records[0]->sobjects[0]->fields->Name

Reading from left-to-right:
1. accessing index 0 (zero) of the "records" array.
2. accessing index 0 (zero) of the "objects" array.
3. accessing the "Name" property of the "fields" SimpleXML element

A more verbose approach would be:

$fld = $queryObject->records;// get the "records" array
$fld = $fld[0]; // get the first index of the array
$fld = $fld->sobjects;   // get the "sobjects" array
$fld = $fld[0];// get the first index of the array
$fld = $fld->fields; // get the "fields" SimpleXML element
$fld = $fld->Name;// get the Name property


Either way, you're "walking" left-to-right, top-to-bottom.


~Ted





On 4-Jun-08, at 3:37 PM, VamVan wrote:


Hello Guys,

Here is the object. How can I get access to the [Name] = access.  
People who
help me with this can you please tell me what is the logic behind  
traversing
the objects and how do you gather the values. Thanks. I am looking  
for an

answer like this $queryResult->f->dsfsdf

QueryResult Object
(
   [queryLocator] =>
   [done] => 1
   [records] => Array
   (
   [0] => SObject Object
   (
   [type] => Contact
   [fields] =>
   [sobjects] => Array
   (
   [0] => SObject Object
   (
   [type] => Account
   [fields] => SimpleXMLElement Object
   (
   [Name] => Access
   )

   )

   )

   )

   )

   [size] => 1
)



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



[PHP] Quickly verifying single word.

2008-06-04 Thread Tyson Vanover
I need a quick way to make sure that a string is a 
single word with no white spaces.  I would prefer that 
it is a command that could fit on a single line.  Or at 
least an if block.


I have a few thoughts on this but it involves things 
like explode(), stripslashes(), etc.


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



[PHP] Objects and Traversing

2008-06-04 Thread VamVan
Hello Guys,

Here is the object. How can I get access to the [Name] = access. People who
help me with this can you please tell me what is the logic behind traversing
the objects and how do you gather the values. Thanks. I am looking for an
answer like this $queryResult->f->dsfsdf

QueryResult Object
(
[queryLocator] =>
[done] => 1
[records] => Array
(
[0] => SObject Object
(
[type] => Contact
[fields] =>
[sobjects] => Array
(
[0] => SObject Object
(
[type] => Account
[fields] => SimpleXMLElement Object
(
[Name] => Access
)

)

)

)

)

[size] => 1
)


RE: [PHP] Avoid object twice

2008-06-04 Thread Boyd, Todd M.
> -Original Message-
> From: Yui Hiroaki [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 04, 2008 12:28 PM
> To: Boyd, Todd M.
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Avoid object twice
> 
> Thanks you for php developer.
> 
> If php can not share the parameter each different
> file, it is not reality of my program.
> 
> If I use include  or requre, php can share the paremeter each file.
> But other files call or execute from original  file.
> 
> setting.php and google_info.php and other.php almost reach
> the my goal, I thought.
> 
> But google_info.php must execute mail() function.
> Or setting.php must have $googlemapkey.

I think it's a fair to assume that no programming language (i.e., PHP)
is able to magically determine the contents of another file/script
without communicating with it in some way (shared memory, pipes,
sockets, the filesystem, middleware, etc.).

How is google_info.php structured? Is it on YOUR server, so that you can
put a page-include at the top of it? If the code that contains your
class (which contains the function to execute mail()) is not included as
part of the executed script, then the executed script will have no idea
that it even exists--let alone have the knowledge of its member
functions.

I think you need to take a step back and focus on fundamental
programming concepts before trying to tackle playing with a Google API.


Todd Boyd
Web Developer

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



Re: [PHP] Regex in PHP

2008-06-04 Thread Robert Cummings
On Wed, 2008-06-04 at 11:18 -0600, Nathan Nobbe wrote:
> On Wed, Jun 4, 2008 at 11:12 AM, Robert Cummings <[EMAIL PROTECTED]>
> wrote:
> 
> > Did you just try to use a test that used a single iteration to prove me
> > wrong? OMFG ponies!!! Loop each one of those 10 million times, use a
> > separate script for each, and use the system time program to
> > appropriately measure the time the system takes.
> 
> 
>  
> $str = 'asSAFAASFDADSfasfjhalskfjhlaseAERQWERQWER;.dafasjhflasfjd';
> $search = 'fdasASDFAafdas';
> 
> $start = microtime();
> 
> for($i = 0; $i < 1000; $i++)
> strpos($str, $search);
> 
> $end = microtime();
> $r1 = $end - $start;
> 
> $start = microtime();
> 
> for($i = 0; $i < 1000; $i++)
> stripos($str, $search);
> 
> $end2 = microtime();
> $r2 = $end2 - $start;
> 
> echo "strpos: $r1\n";
> echo "stripos: $r2\n";
> 
> if($r2 < $r1) {
> echo 'stripos is faster' . PHP_EOL;
> }
> --
> strpos: 0.730519
> stripos: -0.098887
> stripos is faster

Negative time eh!? You're code must be buggy :| The time program works
like this unde rmost nix systems:

time php -q foo.php

And then it returns a report of how much time was taken for various
types of time. I've already sent an email with the appropriate timing of
both versions. BTW, as primtive as microtime() is for this kind of
measurement... you might want to read the manual to use it properly:

http://ca3.php.net/manual/en/function.microtime.php

You probably want:

microtime( true )

> stripos still dominates ;)  what is this system time program you speak of ?
> and, ill put them into separate programs when i get home this evening, and
> have more time to screw around.

It's a simple thought process to understand that unless someone coding
the PHP internals buggered their code, that stripos() cannot possibly be
faster than strpos(). I really don't need benchmarks for something this
simple to know which SHOULD be faster.

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] Regex in PHP

2008-06-04 Thread Robert Cummings
On Wed, 2008-06-04 at 13:12 -0400, Robert Cummings wrote:
> On Wed, 2008-06-04 at 10:56 -0600, Nathan Nobbe wrote:
> > On Wed, Jun 4, 2008 at 10:26 AM, Robert Cummings <[EMAIL PROTECTED]>
> > wrote:
> > 
> > > Nope, case insensitive is slower since you must make two tests for
> > > characters having a lower and upper case version. With case sensitive
> > > comparisons you only need to make a single comparison.
> > 
> > 
> > a quick test shows stripos beating strpos.
> > 
> >  > 
> > $str = 'asSAFAASFDADSfasfjhalskfjhlaseAERQWERQWER;.dafasjhflasfjd';
> > $search = 'fdasASDFAafdas';
> > 
> > $start = microtime();
> > strpos($str, $search);
> > $end = microtime();
> > $r1 = $end - $start;
> > 
> > $start = microtime();
> > stripos($str, $search);
> > $end2 = microtime();
> > $r2 = $end2 - $start;
> > 
> > echo "strpos: $r1\n";
> > echo "stripos: $r2\n";
> > 
> > if($r2 < $r1) {
> > echo 'stripos is faster' . PHP_EOL;
> > }
> > ?>
> 
> Did you just try to use a test that used a single iteration to prove me
> wrong? OMFG ponies!!! Loop each one of those 10 million times, use a
> separate script for each, and use the system time program to
> appropriately measure the time the system takes.

Here's my results on my Athlon 2400, 10 million loops on each type using
your script settings for $str and $search and making 3 runs each time:

strpos()
===
real0m7.133s
user0m6.480s
sys 0m0.020s

real0m6.134s
user0m6.068s
sys 0m0.016s

real0m6.527s
user0m6.476s
sys 0m0.012s

stripos()
===
real0m13.720s
user0m13.517s
sys 0m0.072s

real0m13.158s
user0m13.009s
sys 0m0.016s

real0m13.151s
user0m13.013s
sys 0m0.012s

Now, that's how you test efficiency. Doing a single run is very, very
subject to whatever else your processor might be doing and as such is
usually garbage for any kind of analysis.

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] Avoid object twice

2008-06-04 Thread Yui Hiroaki
Thanks you for php developer.

If php can not share the parameter each different
file, it is not reality of my program.

If I use include  or requre, php can share the paremeter each file.
But other files call or execute from original  file.

setting.php and google_info.php and other.php almost reach
the my goal, I thought.

But google_info.php must execute mail() function.
Or setting.php must have $googlemapkey.

Thank you for a lot.

Regards,
Yui

2008/6/5 Boyd, Todd M. <[EMAIL PROTECTED]>:
>> -Original Message-
>> From: Yui Hiroaki [mailto:[EMAIL PROTECTED]
>> Sent: Wednesday, June 04, 2008 10:03 AM
>> To: Thijs Lensselink
>> Cc: php-general@lists.php.net
>> Subject: Re: [PHP] Avoid object twice
>>
>> NO!
>> That is what I do not want!
>> setting.php need to run mail() function.
>> also setting.php need $googlemapkey.
>>
>> other.php just need $googlemapkey.
>> other .php do not need run mail() function.
>>
>> If I use "include", I will get twice email.
>>
>> Please do advice how to share the $googlemapkey.
>>
>> > I think you are making it way to complicated for yourself.
>> >
>> > So you really just need to share settings between files.
>> > That's exactly what include / require are for.
>> >
>> > settings.php
>> > > >$googlemapkey = "g8ejeUFEUHEU";// example
>> >
>> >function sendMail() {
>> >mail("[EMAIL PROTECTED]","test"."test");
>> >}
>> > ?>
>> >
>> >
>> > Here you include settings.php and are able to use the  mapkey
>> variable.
>> > If you want to send an email just call sendMail();
>> >
>> > other.php
>> > > >include "settings.php";
>> >
>> >// use your google API key any way you want
>> >
>> >sendMail();  // sends mail
>> > ?>
>> >
>> > If you don't need the sendMail(); function. then don't call it.
>> > other2.php
>> > > >   include "settings.php";
>> >
>> >// use your google API key any way you want
>> > ?>
>> >
>> >
>> > I think that's about as clear as i can make it.
>
> For the love of everything good in this world, please take the time to
> READ his reply. Most notably, you should pay attention to how he
> DECLARES a function in "settings.php", rather than EXECUTING a function.
> Since it is just a DECLARATION, you can include that file and the
> function will not be EXECUTED. You can then EXECUTE the function at a
> time of your choosing.
>
> Not everything should run when it is loaded--you built a class ("My")...
> this is the same idea. Rather than a class, this is a function. Think
> about it--member functions of classes don't execute by themselves (save
> for the constructor/destructor, etc.)... you have to invoke them. Same
> with (most) functions. You build it, and then it just sits there until
> you actually tell it to do something. If you don't want your script to
> send mail yet, then don't tell it to use the sendMail() function.
>
> Hope this is resolved,
>
>
> Todd Boyd
> Web Programmer
>
>
>

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



Re: [PHP] Regex in PHP

2008-06-04 Thread Nathan Nobbe
On Wed, Jun 4, 2008 at 11:12 AM, Robert Cummings <[EMAIL PROTECTED]>
wrote:

> Did you just try to use a test that used a single iteration to prove me
> wrong? OMFG ponies!!! Loop each one of those 10 million times, use a
> separate script for each, and use the system time program to
> appropriately measure the time the system takes.




Re: [PHP] Regex in PHP

2008-06-04 Thread Nitsan Bin-Nun
at least he have some humer ;-)

On 04/06/2008, Robert Cummings <[EMAIL PROTECTED]> wrote:
>
> On Wed, 2008-06-04 at 10:56 -0600, Nathan Nobbe wrote:
> > On Wed, Jun 4, 2008 at 10:26 AM, Robert Cummings <[EMAIL PROTECTED]>
> > wrote:
> >
> > > Nope, case insensitive is slower since you must make two tests for
> > > characters having a lower and upper case version. With case sensitive
> > > comparisons you only need to make a single comparison.
> >
> >
> > a quick test shows stripos beating strpos.
> >
> >  >
> > $str = 'asSAFAASFDADSfasfjhalskfjhlaseAERQWERQWER;.dafasjhflasfjd';
> > $search = 'fdasASDFAafdas';
> >
> > $start = microtime();
> > strpos($str, $search);
> > $end = microtime();
> > $r1 = $end - $start;
> >
> > $start = microtime();
> > stripos($str, $search);
> > $end2 = microtime();
> > $r2 = $end2 - $start;
> >
> > echo "strpos: $r1\n";
> > echo "stripos: $r2\n";
> >
> > if($r2 < $r1) {
> > echo 'stripos is faster' . PHP_EOL;
> > }
> > ?>
>
> Did you just try to use a test that used a single iteration to prove me
> wrong? OMFG ponies!!! Loop each one of those 10 million times, use a
> separate script for each, and use the system time program to
> appropriately measure the time the system takes.
>
> :)
>
> 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] Avoid object twice

2008-06-04 Thread David Giragosian
On 6/4/08, Yui Hiroaki <[EMAIL PROTECTED]> wrote:
> Uhmm!
>
> It is sure that function can call from other file.
> But it is NOT EXECUTE mail() function.
>
> How mail function be execute!
>
> Please do more advice.
> You may tire of this mail.

Yes.

David

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



Re: [PHP] Regex in PHP

2008-06-04 Thread Robert Cummings
On Wed, 2008-06-04 at 10:56 -0600, Nathan Nobbe wrote:
> On Wed, Jun 4, 2008 at 10:26 AM, Robert Cummings <[EMAIL PROTECTED]>
> wrote:
> 
> > Nope, case insensitive is slower since you must make two tests for
> > characters having a lower and upper case version. With case sensitive
> > comparisons you only need to make a single comparison.
> 
> 
> a quick test shows stripos beating strpos.
> 
>  
> $str = 'asSAFAASFDADSfasfjhalskfjhlaseAERQWERQWER;.dafasjhflasfjd';
> $search = 'fdasASDFAafdas';
> 
> $start = microtime();
> strpos($str, $search);
> $end = microtime();
> $r1 = $end - $start;
> 
> $start = microtime();
> stripos($str, $search);
> $end2 = microtime();
> $r2 = $end2 - $start;
> 
> echo "strpos: $r1\n";
> echo "stripos: $r2\n";
> 
> if($r2 < $r1) {
> echo 'stripos is faster' . PHP_EOL;
> }
> ?>

Did you just try to use a test that used a single iteration to prove me
wrong? OMFG ponies!!! Loop each one of those 10 million times, use a
separate script for each, and use the system time program to
appropriately measure the time the system takes.

:)

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] Regex in PHP

2008-06-04 Thread Nitsan Bin-Nun
I can't find any good reason for regex in this case.
you can try to split it with explode / stristr / create a function by your
own which goes over the string and check when a @ is catched, something
like:


function GetDomainName ($a)
{

$returnDomain = "";
$beigale = false;
for ($i = 0; $i < strlen($a) && !$beigale; $i++)

if ($a[$i] == '@')
{

for ($z = ($i+1); $z < strlen($a); $z++)
$returnDomain .= $a[$z];
$beigale = true;
}
return $returnDomain;
}



(there is probably a better way to do this - this is just what came up at my
mind right now..)

On 04/06/2008, VamVan <[EMAIL PROTECTED]> wrote:
>
> Hello All,
>
> For example I have these email addressess -
>
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
>
> What would be my PHP function[Regular expression[ to that can give me some
> thing like
>
> yahoo.com
> hotmail.com
> gmail.com
>
> Thanks
>


Re: [PHP] Regex in PHP

2008-06-04 Thread Nathan Nobbe
On Wed, Jun 4, 2008 at 10:26 AM, Robert Cummings <[EMAIL PROTECTED]>
wrote:

> Nope, case insensitive is slower since you must make two tests for
> characters having a lower and upper case version. With case sensitive
> comparisons you only need to make a single comparison.


a quick test shows stripos beating strpos.



-nathan


Re: [PHP] Avoid object twice

2008-06-04 Thread Yui Hiroaki
Uhmm!

It is sure that function can call from other file.
But it is NOT EXECUTE mail() function.

How mail function be execute!

Please do more advice.
You may tire of this mail.


BEST REGARDS,
Yui

2008/6/5 Boyd, Todd M. <[EMAIL PROTECTED]>:
>> -Original Message-
>> From: Yui Hiroaki [mailto:[EMAIL PROTECTED]
>> Sent: Wednesday, June 04, 2008 10:03 AM
>> To: Thijs Lensselink
>> Cc: php-general@lists.php.net
>> Subject: Re: [PHP] Avoid object twice
>>
>> NO!
>> That is what I do not want!
>> setting.php need to run mail() function.
>> also setting.php need $googlemapkey.
>>
>> other.php just need $googlemapkey.
>> other .php do not need run mail() function.
>>
>> If I use "include", I will get twice email.
>>
>> Please do advice how to share the $googlemapkey.
>>
>> > I think you are making it way to complicated for yourself.
>> >
>> > So you really just need to share settings between files.
>> > That's exactly what include / require are for.
>> >
>> > settings.php
>> > > >$googlemapkey = "g8ejeUFEUHEU";// example
>> >
>> >function sendMail() {
>> >mail("[EMAIL PROTECTED]","test"."test");
>> >}
>> > ?>
>> >
>> >
>> > Here you include settings.php and are able to use the  mapkey
>> variable.
>> > If you want to send an email just call sendMail();
>> >
>> > other.php
>> > > >include "settings.php";
>> >
>> >// use your google API key any way you want
>> >
>> >sendMail();  // sends mail
>> > ?>
>> >
>> > If you don't need the sendMail(); function. then don't call it.
>> > other2.php
>> > > >   include "settings.php";
>> >
>> >// use your google API key any way you want
>> > ?>
>> >
>> >
>> > I think that's about as clear as i can make it.
>
> For the love of everything good in this world, please take the time to
> READ his reply. Most notably, you should pay attention to how he
> DECLARES a function in "settings.php", rather than EXECUTING a function.
> Since it is just a DECLARATION, you can include that file and the
> function will not be EXECUTED. You can then EXECUTE the function at a
> time of your choosing.
>
> Not everything should run when it is loaded--you built a class ("My")...
> this is the same idea. Rather than a class, this is a function. Think
> about it--member functions of classes don't execute by themselves (save
> for the constructor/destructor, etc.)... you have to invoke them. Same
> with (most) functions. You build it, and then it just sits there until
> you actually tell it to do something. If you don't want your script to
> send mail yet, then don't tell it to use the sendMail() function.
>
> Hope this is resolved,
>
>
> Todd Boyd
> Web Programmer
>
>
>

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



Re: [PHP] Regex in PHP

2008-06-04 Thread Robert Cummings
On Wed, 2008-06-04 at 10:18 -0600, Nathan Nobbe wrote:
> On Wed, Jun 4, 2008 at 10:10 AM, Richard Heyes <[EMAIL PROTECTED]> wrote:
> 
> > Hi,
> >
> >  and the case insensitive versions are a hair faster still ;)
> >>
> >
> > Are they? I always thought that case-sensitive functions were faster
> > because they have to test fewer comparisons. Eg To test if i == I in a
> > case-insensitive fashion requires two comparisons (i == I and i == i)
> > whereas a case-sensitive comparison requires only one (i == i).
> 
> 
> umm, isnt it like the other way around.  in the case of case-sensitive, you
> have to be able to distinguish between i and I, whereas w/ the case
> insensitive, you dont care so, basically, you strtolower() first thing, then
> just compare to lower case characters.

Nope, case insensitive is slower since you must make two tests for
characters having a lower and upper case version. With case sensitive
comparisons you only need to make a single comparison.

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] Avoid object twice

2008-06-04 Thread Yui Hiroaki
Thank you for all!

I try to use script.
But it does not run correctly.

It means that setting.php never call sendMail() from google_info.php.

Are you sure that it is possible to call function from other file?


Best Regards,
Yui

2008/6/5 Boyd, Todd M. <[EMAIL PROTECTED]>:
>> -Original Message-
>> From: Yui Hiroaki [mailto:[EMAIL PROTECTED]
>> Sent: Wednesday, June 04, 2008 10:03 AM
>> To: Thijs Lensselink
>> Cc: php-general@lists.php.net
>> Subject: Re: [PHP] Avoid object twice
>>
>> NO!
>> That is what I do not want!
>> setting.php need to run mail() function.
>> also setting.php need $googlemapkey.
>>
>> other.php just need $googlemapkey.
>> other .php do not need run mail() function.
>>
>> If I use "include", I will get twice email.
>>
>> Please do advice how to share the $googlemapkey.
>>
>> > I think you are making it way to complicated for yourself.
>> >
>> > So you really just need to share settings between files.
>> > That's exactly what include / require are for.
>> >
>> > settings.php
>> > > >$googlemapkey = "g8ejeUFEUHEU";// example
>> >
>> >function sendMail() {
>> >mail("[EMAIL PROTECTED]","test"."test");
>> >}
>> > ?>
>> >
>> >
>> > Here you include settings.php and are able to use the  mapkey
>> variable.
>> > If you want to send an email just call sendMail();
>> >
>> > other.php
>> > > >include "settings.php";
>> >
>> >// use your google API key any way you want
>> >
>> >sendMail();  // sends mail
>> > ?>
>> >
>> > If you don't need the sendMail(); function. then don't call it.
>> > other2.php
>> > > >   include "settings.php";
>> >
>> >// use your google API key any way you want
>> > ?>
>> >
>> >
>> > I think that's about as clear as i can make it.
>
> For the love of everything good in this world, please take the time to
> READ his reply. Most notably, you should pay attention to how he
> DECLARES a function in "settings.php", rather than EXECUTING a function.
> Since it is just a DECLARATION, you can include that file and the
> function will not be EXECUTED. You can then EXECUTE the function at a
> time of your choosing.
>
> Not everything should run when it is loaded--you built a class ("My")...
> this is the same idea. Rather than a class, this is a function. Think
> about it--member functions of classes don't execute by themselves (save
> for the constructor/destructor, etc.)... you have to invoke them. Same
> with (most) functions. You build it, and then it just sits there until
> you actually tell it to do something. If you don't want your script to
> send mail yet, then don't tell it to use the sendMail() function.
>
> Hope this is resolved,
>
>
> Todd Boyd
> Web Programmer
>
>
>

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



Re: [PHP] Regex in PHP

2008-06-04 Thread Nathan Nobbe
On Wed, Jun 4, 2008 at 10:10 AM, Richard Heyes <[EMAIL PROTECTED]> wrote:

> Hi,
>
>  and the case insensitive versions are a hair faster still ;)
>>
>
> Are they? I always thought that case-sensitive functions were faster
> because they have to test fewer comparisons. Eg To test if i == I in a
> case-insensitive fashion requires two comparisons (i == I and i == i)
> whereas a case-sensitive comparison requires only one (i == i).


umm, isnt it like the other way around.  in the case of case-sensitive, you
have to be able to distinguish between i and I, whereas w/ the case
insensitive, you dont care so, basically, you strtolower() first thing, then
just compare to lower case characters.

-nathan


Re: [PHP] Regex in PHP

2008-06-04 Thread Richard Heyes

Hi,


and the case insensitive versions are a hair faster still ;)


Are they? I always thought that case-sensitive functions were faster 
because they have to test fewer comparisons. Eg To test if i == I in a 
case-insensitive fashion requires two comparisons (i == I and i == i) 
whereas a case-sensitive comparison requires only one (i == i).


Cheers.

--
Richard Heyes

++
| Access SSH with a Windows mapped drive |
|http://www.phpguru.org/sftpdrive|
++

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



RE: [PHP] Avoid object twice

2008-06-04 Thread Boyd, Todd M.
> -Original Message-
> From: Yui Hiroaki [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 04, 2008 10:03 AM
> To: Thijs Lensselink
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Avoid object twice
> 
> NO!
> That is what I do not want!
> setting.php need to run mail() function.
> also setting.php need $googlemapkey.
> 
> other.php just need $googlemapkey.
> other .php do not need run mail() function.
> 
> If I use "include", I will get twice email.
> 
> Please do advice how to share the $googlemapkey.
>
> > I think you are making it way to complicated for yourself.
> >
> > So you really just need to share settings between files.
> > That's exactly what include / require are for.
> >
> > settings.php
> >  >$googlemapkey = "g8ejeUFEUHEU";// example
> >
> >function sendMail() {
> >mail("[EMAIL PROTECTED]","test"."test");
> >}
> > ?>
> >
> >
> > Here you include settings.php and are able to use the  mapkey
> variable.
> > If you want to send an email just call sendMail();
> >
> > other.php
> >  >include "settings.php";
> >
> >// use your google API key any way you want
> >
> >sendMail();  // sends mail
> > ?>
> >
> > If you don't need the sendMail(); function. then don't call it.
> > other2.php
> >  >   include "settings.php";
> >
> >// use your google API key any way you want
> > ?>
> >
> >
> > I think that's about as clear as i can make it.

For the love of everything good in this world, please take the time to
READ his reply. Most notably, you should pay attention to how he
DECLARES a function in "settings.php", rather than EXECUTING a function.
Since it is just a DECLARATION, you can include that file and the
function will not be EXECUTED. You can then EXECUTE the function at a
time of your choosing.

Not everything should run when it is loaded--you built a class ("My")...
this is the same idea. Rather than a class, this is a function. Think
about it--member functions of classes don't execute by themselves (save
for the constructor/destructor, etc.)... you have to invoke them. Same
with (most) functions. You build it, and then it just sits there until
you actually tell it to do something. If you don't want your script to
send mail yet, then don't tell it to use the sendMail() function.

Hope this is resolved,


Todd Boyd
Web Programmer



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



[PHP] Re: Regex in PHP

2008-06-04 Thread Shawn McKenzie

VamVan wrote:

Hello All,

For example I have these email addressess -

[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

What would be my PHP function[Regular expression[ to that can give me some
thing like

yahoo.com
hotmail.com
gmail.com

Thanks




Or if you know that the address is valid and you may need both parts:

list($name, $domain) = explode('@', '[EMAIL PROTECTED]');


-Shawn

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



Re: [PHP] slowness mystery

2008-06-04 Thread Rene Veerman
it's equally slow when viewed from a local machine running
firefox+apache+php+mysql, or from the internet hoster i use..

On Wed, Jun 4, 2008 at 5:48 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:

> On Wed, Jun 4, 2008 at 8:49 AM, Rene Veerman <[EMAIL PROTECTED]> wrote:
>
>> Using a statis .js file costs 3.54 seconds.
>>
>> Should i suspect apache now?
>
>
> is this something youre fetching over a local network, or are you going out
> over the internet to get it ?
>
> -nathan
>


[PHP] Re: Regex in PHP

2008-06-04 Thread Al

$user = trim(strstr($email, '@'), '@);


VamVan wrote:

Hello All,

For example I have these email addressess -

[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

What would be my PHP function[Regular expression[ to that can give me some
thing like

yahoo.com
hotmail.com
gmail.com

Thanks



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



Re: [PHP] slowness mystery

2008-06-04 Thread Nathan Nobbe
On Wed, Jun 4, 2008 at 8:49 AM, Rene Veerman <[EMAIL PROTECTED]> wrote:

> Using a statis .js file costs 3.54 seconds.
>
> Should i suspect apache now?


is this something youre fetching over a local network, or are you going out
over the internet to get it ?

-nathan


Re: [PHP] slowness mystery

2008-06-04 Thread Eric Butera
On Wed, Jun 4, 2008 at 10:01 AM, Bastien Koert <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>> Make it write out a static .js file and link to that.  Apache can
>> serve up files like that way faster directly than piping it through
>> php.  If you don't want to go through that hassle, make sure you have
>> a far future expire header on the file so that the client does not
>> request it each time.
>
> Eric,
>
> How do I do that? I generally embed the js file in the html that gets sent
> down
>
> 
> 
> 
>
>
> How can I set the expiry header? I know I can use php to send that header,
> but how when its as above? Is that an apache setting?
>
>
> Thanks,
>
> --
>
> Bastien
>
> Cat, the other other white meat


http://www.thinkvitamin.com/features/webapps/serving-javascript-fast

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



Re: [PHP] slowness mystery

2008-06-04 Thread Eric Butera
On Wed, Jun 4, 2008 at 8:45 AM, Rene Veerman <[EMAIL PROTECTED]> wrote:
> Ok, i changed from reading from the database to reading from a file.
> It now clocks at 3.37seconds for the malignant peace of javascript..
> Still too slow :(
>
> Timing the readfile statement that outputs the cache file, is at 0.00109
> seconds according to a measurement done with microtime()
> It seems that this is not correct, because if i remove the readfile
> statement, things speed up to 120 milliseconds (from 3.37seconds)..
>
> Some more help would be greatly appreciated..
>
> On Wed, Jun 4, 2008 at 9:20 AM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
>
>> On Wed, Jun 4, 2008 at 3:05 AM, Rene Veerman <[EMAIL PROTECTED]> wrote:
>>
>>> Hi..
>>>
>>> I've built a cms that's running into a serious speedbump.
>>> I load several sets of javascript through a custom built db
>>> caching&compression system.
>>> Loading it without caching and compression takes between 2 and 3 seconds
>>> for
>>> the entire app, 112Kb javascript.
>>>
>>> The caching system first compresses/obfusicates the requested
>>> source-files,
>>> then gzcompress()es that and stores the result in my database.
>>>
>>> The next time the page is requested, the caching system detects the cached
>>> copy, and outputs that with an echo statement.
>>>
>>> One of these code bundles that i request takes over 6 full seconds to
>>> load.
>>> It's the same 122Kb obfusi-compressed to 52Kb.
>>> Even without obfusication, it takes 6 seconds to load when taken from the
>>> database.
>>> So it's not the browser being slow in parsing the obfusicated code.
>>> Firebug's "net"-tab shows this one snippet taking 6 seconds. I don't know
>>> exactly what that measures, just the transit time i hope..
>>>
>>> I suspected the database query, but retrieval takes less than a
>>> millisecond.
>>> So does the 'echo' statement that outputs it.
>>>
>>> I'm really puzzled as to what can cause such a delay.
>>>
>>
>> i think putting the js in the database at all, and then using php to
>> retrieve it is unnecessary overhead.  i would put the cached contents on
>> disc, and refer browsers to a direct url.  maybe you could just put the
>> contents of one of your compressed files on disc, and request it from the
>> browser, time that, and see if it gets you anywhere.
>>
>> also, i would check into some of the resources yahoo has in this dept.  for
>> example, the ySlow firebug plugin,
>>
>> http://developer.yahoo.com/yslow/
>> there are additional resources as well, and they even have a really slick
>> js compressor, freely available.  its so slick in fact, that it will reduce
>> the length of variable identifiers that are safe to do on because those
>> variables happen to be closures.  neat stuff.
>>
>> -nathan
>>
>

Maybe you can work out some mod_deflate/gz action with apache to
compress it for all browsers except IE?

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



RE: [PHP] Avoid object twice

2008-06-04 Thread Ford, Mike
On 04 June 2008 16:03, Yui Hiroaki advised:

> NO!
> That is what I do not want!
> setting.php need to run mail() function.
> also setting.php need $googlemapkey.
> 
> other.php just need $googlemapkey.
> other .php do not need run mail() function.
> 
> If I use "include", I will get twice email.

Same answer as Thijs gave, just with the filenames moved around:

 google_info.php
 


 setting.php
 

 other.php
 

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] Avoid object twice

2008-06-04 Thread Yui Hiroaki
NO!
That is what I do not want!
setting.php need to run mail() function.
also setting.php need $googlemapkey.

other.php just need $googlemapkey.
other .php do not need run mail() function.

If I use "include", I will get twice email.

Please do advice how to share the $googlemapkey.

Regards,
Yui

2008/6/4 Thijs Lensselink <[EMAIL PROTECTED]>:
> Quoting Yui Hiroaki <[EMAIL PROTECTED]>:
>
>> My problem is that I would like to share the parameter.
>> For instance, goolge map key.
>>
>> There are actually two files.
>>
>> example,
>>
>> main.php
>> > $googlemapkey="g8ejeUFEUHEU";// example
>> mail("[EMAIL PROTECTED]","test"."test");
>> ?>
>>
>> Above is part of code;
>> I will excute main.php program.
>> then other.php run
>> But when other.php run, other.php requre $googlemapkey.
>> Of couse, I can get $googlemapkey if I use "include" or "require".
>> But if I use "include" or "require",
>> mail("[EMAIL PROTECTED]","test"."test") run again.
>>
>> So this program send twice email. It is NOT GOOD.
>> I juse send $googlemapkey from mail.php to other.php
>>
>>
>> Please advice if you have any solution.
>>
>>
>> Regards,
>> Yui
>>
>>
>> 2008/6/4 Boyd, Todd M. <[EMAIL PROTECTED]>:

 I knew it .

 But "Hello" and "Good" is different file.
 I would like to get "Good" from b.php.

 Please tell me goo advice.
 Yui

 2008/6/4 Boyd, Todd M. <[EMAIL PROTECTED]>:
 >> Thank you for your advice me!
 >>
 >> -My.php---
 >> >>> >>
 >> Class My{
 >>private $word;
 >>function __construct($getword){
 >> $this->word=$getword;
 >>}
 >>public function buff(){
 >> mail("[EMAIL PROTECTED]","test","test");
 >>}
 >> }
 >> ?>
 >> --
 >>
 >> --b.php
 >> >>> >>   function __autoload($class_name) {
 >>   include_once $class_name . '.php';
 >>   }
 >>
 >>
 >> $objref=new My("Good");
 >> $objref->buff();
 >> ?>
 >> 
 >>
 >> --c.php--
 >> >>> >>   function __autoload($class_name) {
 >>   include_once $class_name . '.php';
 >>   }
 >>
 >> $obj=new My("Hello");
 >> $obj->buff();
 >> --
 >>
 >> That is what I want to try.
 >>
 >> When c.php run, Mail() function run // < it is OK
 >> When b.php run, it also run Mail() fuction. // it is NOT OK
 >>
 >> I would like to run Mail() function one time only from c.php.
 >> However I also get prameter which declare "Good" in b.php
 >>
 >> Now when c.php and b.php run, the program send twice email. That is
 > not
 >> good!!
 >> I would like to run c.php and b.php, then the program, which is
 Mail()
 >> function, get one email and get  "Good"  from b.php
 >
 > You are not making any sense... if you only want the Mail() function
 to
 > run once, then ONLY CALL ->BUFF() ONE TIME. It's that simple. You
>>>
>>> are

 > mailing twice because you call buff() in two separate places--and
 buff()
 > in turn calls Mail(). I don't understand your problem.
 >
 > $objref = new My("Good");
 > $obj = new My("Hello");
 > $obj->buff();
 >
 > Bam. You get Hello, Good, and it sends one e-mail. Since you are
 > completely abstracting your code from its real-world application,
 that's
 > the best I can do.
>>>
>>> I still don't get it. Please explain to me WHY this is not a solution to
>>> your problem?
>>>
>>> ===
>>> My.php
>>> ===
>>> >> Class My{
>>>  private $word;
>>>  function __construct($getword){
>>>   $this->word=$getword;
>>>  }
>>>  public function buff(){
>>>   mail("[EMAIL PROTECTED]","test","test");
>>>  }
>>> }
>>> ?>
>>>
>>> ===
>>> b.php
>>> ===
>>> >>   function __autoload($class_name) {
>>>   include_once $class_name . '.php';
>>>   }
>>>
>>>   $objref=new My("Good");
>>>   // $objref->buff(); NOTICE HOW THIS IS COMMENTED OUT!!!
>>> ?>
>>>
>>> ===
>>> c.php
>>> ===
>>> >>   function __autoload($class_name) {
>>>   include_once $class_name . '.php';
>>>   }
>>>
>>>   $obj=new My("Hello");
>>>   $obj->buff();   // MAIL() IS EXECUTED HERE
>>> ?>
>>>
>>> If that doesn't work, then here are my questions:
>>>
>>> 1.) What on earth are you ACTUALLY trying to do?
>>> 2.) Does ->buff() NEED to be called for each instance of My()?
>>> 3.) Are you wanting multiple instances of this class to share data?
>>> 4.) If (3), then are you familiar with the STATIC property?
>>>
>>>
>>> Todd Boyd
>>> Web Programmer
>>>
>>
>
> I think you are making it way to complicated for yourself.
>
> So you really just need to share settings between files.
> That's exactly what include / require are for.
>
> settings

Re: [PHP] slowness mystery

2008-06-04 Thread Thijs Lensselink

Quoting Rene Veerman <[EMAIL PROTECTED]>:


Using a statis .js file costs 3.54 seconds.

Should i suspect apache now?



You could try running the php script from the command line.
And see how long it takes. Just to make sure if it's apache or PHP.

Profiling the script will also help tracking down the bottleneck.
Give xdebug a try : http://xdebug.org/docs/profiler

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



Re: [PHP] slowness mystery

2008-06-04 Thread Rene Veerman
Using a statis .js file costs 3.54 seconds.

Should i suspect apache now?


Re: [PHP] Avoid object twice

2008-06-04 Thread Thijs Lensselink

Quoting Yui Hiroaki <[EMAIL PROTECTED]>:


My problem is that I would like to share the parameter.
For instance, goolge map key.

There are actually two files.

example,

main.php


Above is part of code;
I will excute main.php program.
then other.php run
But when other.php run, other.php requre $googlemapkey.
Of couse, I can get $googlemapkey if I use "include" or "require".
But if I use "include" or "require",
mail("[EMAIL PROTECTED]","test"."test") run again.

So this program send twice email. It is NOT GOOD.
I juse send $googlemapkey from mail.php to other.php


Please advice if you have any solution.


Regards,
Yui


2008/6/4 Boyd, Todd M. <[EMAIL PROTECTED]>:

I knew it .

But "Hello" and "Good" is different file.
I would like to get "Good" from b.php.

Please tell me goo advice.
Yui

2008/6/4 Boyd, Todd M. <[EMAIL PROTECTED]>:
>> Thank you for your advice me!
>>
>> -My.php---
>> >
>> Class My{
>>private $word;
>>function __construct($getword){
>> $this->word=$getword;
>>}
>>public function buff(){
>> mail("[EMAIL PROTECTED]","test","test");
>>}
>> }
>> ?>
>> --
>>
>> --b.php
>> >   function __autoload($class_name) {
>>   include_once $class_name . '.php';
>>   }
>>
>>
>> $objref=new My("Good");
>> $objref->buff();
>> ?>
>> 
>>
>> --c.php--
>> >   function __autoload($class_name) {
>>   include_once $class_name . '.php';
>>   }
>>
>> $obj=new My("Hello");
>> $obj->buff();
>> --
>>
>> That is what I want to try.
>>
>> When c.php run, Mail() function run // < it is OK
>> When b.php run, it also run Mail() fuction. // it is NOT OK
>>
>> I would like to run Mail() function one time only from c.php.
>> However I also get prameter which declare "Good" in b.php
>>
>> Now when c.php and b.php run, the program send twice email. That is
> not
>> good!!
>> I would like to run c.php and b.php, then the program, which is
Mail()
>> function, get one email and get  "Good"  from b.php
>
> You are not making any sense... if you only want the Mail() function
to
> run once, then ONLY CALL ->BUFF() ONE TIME. It's that simple. You

are

> mailing twice because you call buff() in two separate places--and
buff()
> in turn calls Mail(). I don't understand your problem.
>
> $objref = new My("Good");
> $obj = new My("Hello");
> $obj->buff();
>
> Bam. You get Hello, Good, and it sends one e-mail. Since you are
> completely abstracting your code from its real-world application,
that's
> the best I can do.


I still don't get it. Please explain to me WHY this is not a solution to
your problem?

===
My.php
===
word=$getword;
  }
  public function buff(){
   mail("[EMAIL PROTECTED]","test","test");
  }
}
?>

===
b.php
===
buff(); NOTICE HOW THIS IS COMMENTED OUT!!!
?>

===
c.php
===
buff();   // MAIL() IS EXECUTED HERE
?>

If that doesn't work, then here are my questions:

1.) What on earth are you ACTUALLY trying to do?
2.) Does ->buff() NEED to be called for each instance of My()?
3.) Are you wanting multiple instances of this class to share data?
4.) If (3), then are you familiar with the STATIC property?


Todd Boyd
Web Programmer





I think you are making it way to complicated for yourself.

So you really just need to share settings between files.
That's exactly what include / require are for.

settings.php



Here you include settings.php and are able to use the  mapkey variable.
If you want to send an email just call sendMail();

other.php


If you don't need the sendMail(); function. then don't call it.
other2.php



I think that's about as clear as i can make it.

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



RE: [PHP] About MS SQL Connections...

2008-06-04 Thread Lic. Eduardo R. Hernández Osorio
I use ADOdb Recordset object to accomplish the connection. 
The error message is: 
mssql error: [: ] in EXECUTE("SELECT * FROM ")




Eduardo Ricardo Hernández Osorio

Técnico Telecomunicaciones Aeronáuticas

U.T.B Servicios Aeronáuticos, ECASA s.a.

Aeropuerto Internacional "Frank País García"

Tel: (53) (24) 474569

email: [EMAIL PROTECTED]

"...de buenas intenciones está empedrado el camino al infierno..."

-Mensaje original-
De: Dan Joseph [mailto:[EMAIL PROTECTED] 
Enviado el: 03 June 2008 13:47
Para: PHP
Asunto: Re: [PHP] About MS SQL Connections...

On Tue, Jun 3, 2008 at 1:43 PM, Lic. Eduardo R. Hernández Osorio <
[EMAIL PROTECTED]> wrote:

>  Hello.
>
> I have a problem with a Desktop Edition MS SQL Server servant, when I try
> to get connected to crosswise of PHP functions to this, it provokes an
> error and I can not achieve the connection. However when I try the same
> operation on an Standard Edition MS SQL Server servant I am able to
> accomplish the connection.  Would you help me to resolve this problem?
> Expecting for your help,
>
> Richard
>
> 
>
> Eduardo Ricardo Hernández Osorio
>
> Técnico Telecomunicaciones Aeronáuticas
>
> U.T.B Servicios Aeronáuticos, ECASA s.a.
>
> Aeropuerto Internacional "Frank País García"
>
> Tel: (53) (24) 474569
>
> email: [EMAIL PROTECTED]
>
> "...de buenas intenciones está empedrado el camino al infierno..."
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Can you post your code and error so we can take a look?

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."



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



Re: [PHP] Avoid object twice

2008-06-04 Thread Yui Hiroaki
My problem is that I would like to share the parameter.
For instance, goolge map key.

There are actually two files.

example,

main.php


Above is part of code;
I will excute main.php program.
then other.php run
But when other.php run, other.php requre $googlemapkey.
Of couse, I can get $googlemapkey if I use "include" or "require".
But if I use "include" or "require",
mail("[EMAIL PROTECTED]","test"."test") run again.

So this program send twice email. It is NOT GOOD.
I juse send $googlemapkey from mail.php to other.php


Please advice if you have any solution.


Regards,
Yui


2008/6/4 Boyd, Todd M. <[EMAIL PROTECTED]>:
>> I knew it .
>>
>> But "Hello" and "Good" is different file.
>> I would like to get "Good" from b.php.
>>
>> Please tell me goo advice.
>> Yui
>>
>> 2008/6/4 Boyd, Todd M. <[EMAIL PROTECTED]>:
>> >> Thank you for your advice me!
>> >>
>> >> -My.php---
>> >> > >>
>> >> Class My{
>> >>private $word;
>> >>function __construct($getword){
>> >> $this->word=$getword;
>> >>}
>> >>public function buff(){
>> >> mail("[EMAIL PROTECTED]","test","test");
>> >>}
>> >> }
>> >> ?>
>> >> --
>> >>
>> >> --b.php
>> >> > >>   function __autoload($class_name) {
>> >>   include_once $class_name . '.php';
>> >>   }
>> >>
>> >>
>> >> $objref=new My("Good");
>> >> $objref->buff();
>> >> ?>
>> >> 
>> >>
>> >> --c.php--
>> >> > >>   function __autoload($class_name) {
>> >>   include_once $class_name . '.php';
>> >>   }
>> >>
>> >> $obj=new My("Hello");
>> >> $obj->buff();
>> >> --
>> >>
>> >> That is what I want to try.
>> >>
>> >> When c.php run, Mail() function run // < it is OK
>> >> When b.php run, it also run Mail() fuction. // it is NOT OK
>> >>
>> >> I would like to run Mail() function one time only from c.php.
>> >> However I also get prameter which declare "Good" in b.php
>> >>
>> >> Now when c.php and b.php run, the program send twice email. That is
>> > not
>> >> good!!
>> >> I would like to run c.php and b.php, then the program, which is
>> Mail()
>> >> function, get one email and get  "Good"  from b.php
>> >
>> > You are not making any sense... if you only want the Mail() function
>> to
>> > run once, then ONLY CALL ->BUFF() ONE TIME. It's that simple. You
> are
>> > mailing twice because you call buff() in two separate places--and
>> buff()
>> > in turn calls Mail(). I don't understand your problem.
>> >
>> > $objref = new My("Good");
>> > $obj = new My("Hello");
>> > $obj->buff();
>> >
>> > Bam. You get Hello, Good, and it sends one e-mail. Since you are
>> > completely abstracting your code from its real-world application,
>> that's
>> > the best I can do.
>
> I still don't get it. Please explain to me WHY this is not a solution to
> your problem?
>
> ===
> My.php
> ===
>  Class My{
>   private $word;
>   function __construct($getword){
>$this->word=$getword;
>   }
>   public function buff(){
>mail("[EMAIL PROTECTED]","test","test");
>   }
> }
> ?>
>
> ===
> b.php
> ===
> function __autoload($class_name) {
>include_once $class_name . '.php';
>}
>
>$objref=new My("Good");
>// $objref->buff(); NOTICE HOW THIS IS COMMENTED OUT!!!
> ?>
>
> ===
> c.php
> ===
> function __autoload($class_name) {
>include_once $class_name . '.php';
>}
>
>$obj=new My("Hello");
>$obj->buff();   // MAIL() IS EXECUTED HERE
> ?>
>
> If that doesn't work, then here are my questions:
>
> 1.) What on earth are you ACTUALLY trying to do?
> 2.) Does ->buff() NEED to be called for each instance of My()?
> 3.) Are you wanting multiple instances of this class to share data?
> 4.) If (3), then are you familiar with the STATIC property?
>
>
> Todd Boyd
> Web Programmer
>

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



RE: [PHP] A problem with fgets()

2008-06-04 Thread Ford, Mike
On 30 May 2008 02:56, Usamah M. Ali advised:

> So you're confirming that fgets() doesn't necessarily read a whole
> line? This user note existed on the manual's page of fgets() since
> 2004 and nobody deleted it or commented about:
> 
> rstefanowski at wi dot ps dot pl
> 12-Aug-2004 09:03
> 
> "Take note that fgets() reads 'whole lines'. This means that if a file
> pointer is in the middle of the line (eg. after fscanf()), fgets()
> will read the following line, not the remaining part of the currnet
> line. You could expect it would read until the end of the current
> line, but it doesn't. It skips to the next full line."
> 
> That was my source of confusion.

Yes, I agree that that note is complete hogwash, and have just deleted
it!

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] problem with "include" directive under XHTML

2008-06-04 Thread Robert Huff

Uh, guys?  Nevermind.
To quote someone's .sig: "The truth was out there, but the lies
were in my mind."  I cleared out a couple of mis-conceptions, and
the problem went away.
Sorry for the noise.



Robert Huff




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



Re: [PHP] slowness mystery

2008-06-04 Thread Bastien Koert
>
>
>
>
> Make it write out a static .js file and link to that.  Apache can
> serve up files like that way faster directly than piping it through
> php.  If you don't want to go through that hassle, make sure you have
> a far future expire header on the file so that the client does not
> request it each time.
>

Eric,

How do I do that? I generally embed the js file in the html that gets sent
down






How can I set the expiry header? I know I can use php to send that header,
but how when its as above? Is that an apache setting?


Thanks,

-- 

Bastien

Cat, the other other white meat


RE: [PHP] Avoid object twice

2008-06-04 Thread Boyd, Todd M.
> I knew it .
> 
> But "Hello" and "Good" is different file.
> I would like to get "Good" from b.php.
> 
> Please tell me goo advice.
> Yui
> 
> 2008/6/4 Boyd, Todd M. <[EMAIL PROTECTED]>:
> >> Thank you for your advice me!
> >>
> >> -My.php---
> >>  >>
> >> Class My{
> >>private $word;
> >>function __construct($getword){
> >> $this->word=$getword;
> >>}
> >>public function buff(){
> >> mail("[EMAIL PROTECTED]","test","test");
> >>}
> >> }
> >> ?>
> >> --
> >>
> >> --b.php
> >>  >>   function __autoload($class_name) {
> >>   include_once $class_name . '.php';
> >>   }
> >>
> >>
> >> $objref=new My("Good");
> >> $objref->buff();
> >> ?>
> >> 
> >>
> >> --c.php--
> >>  >>   function __autoload($class_name) {
> >>   include_once $class_name . '.php';
> >>   }
> >>
> >> $obj=new My("Hello");
> >> $obj->buff();
> >> --
> >>
> >> That is what I want to try.
> >>
> >> When c.php run, Mail() function run // < it is OK
> >> When b.php run, it also run Mail() fuction. // it is NOT OK
> >>
> >> I would like to run Mail() function one time only from c.php.
> >> However I also get prameter which declare "Good" in b.php
> >>
> >> Now when c.php and b.php run, the program send twice email. That is
> > not
> >> good!!
> >> I would like to run c.php and b.php, then the program, which is
> Mail()
> >> function, get one email and get  "Good"  from b.php
> >
> > You are not making any sense... if you only want the Mail() function
> to
> > run once, then ONLY CALL ->BUFF() ONE TIME. It's that simple. You
are
> > mailing twice because you call buff() in two separate places--and
> buff()
> > in turn calls Mail(). I don't understand your problem.
> >
> > $objref = new My("Good");
> > $obj = new My("Hello");
> > $obj->buff();
> >
> > Bam. You get Hello, Good, and it sends one e-mail. Since you are
> > completely abstracting your code from its real-world application,
> that's
> > the best I can do.

I still don't get it. Please explain to me WHY this is not a solution to
your problem?

===
My.php
===
word=$getword;
   }
   public function buff(){
mail("[EMAIL PROTECTED]","test","test");
   }
}
?>

===
b.php
===
buff(); NOTICE HOW THIS IS COMMENTED OUT!!!
?>

===
c.php
===
buff();   // MAIL() IS EXECUTED HERE
?>

If that doesn't work, then here are my questions:

1.) What on earth are you ACTUALLY trying to do?
2.) Does ->buff() NEED to be called for each instance of My()?
3.) Are you wanting multiple instances of this class to share data?
4.) If (3), then are you familiar with the STATIC property?


Todd Boyd
Web Programmer

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



Re: [PHP] Avoid object twice

2008-06-04 Thread Yui Hiroaki
I knew it .

But "Hello" and "Good" is different file.
I would like to get "Good" from b.php.

Please tell me goo advice.
Yui

2008/6/4 Boyd, Todd M. <[EMAIL PROTECTED]>:
>> Thank you for your advice me!
>>
>> -My.php---
>> >
>> Class My{
>>private $word;
>>function __construct($getword){
>> $this->word=$getword;
>>}
>>public function buff(){
>> mail("[EMAIL PROTECTED]","test","test");
>>}
>> }
>> ?>
>> --
>>
>> --b.php
>> >   function __autoload($class_name) {
>>   include_once $class_name . '.php';
>>   }
>>
>>
>> $objref=new My("Good");
>> $objref->buff();
>> ?>
>> 
>>
>> --c.php--
>> >   function __autoload($class_name) {
>>   include_once $class_name . '.php';
>>   }
>>
>> $obj=new My("Hello");
>> $obj->buff();
>> --
>>
>> That is what I want to try.
>>
>> When c.php run, Mail() function run // < it is OK
>> When b.php run, it also run Mail() fuction. // it is NOT OK
>>
>> I would like to run Mail() function one time only from c.php.
>> However I also get prameter which declare "Good" in b.php
>>
>> Now when c.php and b.php run, the program send twice email. That is
> not
>> good!!
>> I would like to run c.php and b.php, then the program, which is Mail()
>> function, get one email and get  "Good"  from b.php
>
> You are not making any sense... if you only want the Mail() function to
> run once, then ONLY CALL ->BUFF() ONE TIME. It's that simple. You are
> mailing twice because you call buff() in two separate places--and buff()
> in turn calls Mail(). I don't understand your problem.
>
> $objref = new My("Good");
> $obj = new My("Hello");
> $obj->buff();
>
> Bam. You get Hello, Good, and it sends one e-mail. Since you are
> completely abstracting your code from its real-world application, that's
> the best I can do.
>
>
> Todd Boyd
> Web Programmer
>
>
>
>

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



Re: [PHP] Avoid object twice

2008-06-04 Thread Yui Hiroaki
Thank you for your good advice.

I excute c.php I did not get "Good" from b.php.

How can I get "Good" from b.php.

Regards,
Yui

2008/6/4 Thijs Lensselink <[EMAIL PROTECTED]>:
> Quoting Yui Hiroaki <[EMAIL PROTECTED]>:
>
>> Thank you for your advice me!
>>
>>
>>
>> -My.php---
>> >
>> Class My{
>>   private $word;
>>   function __construct($getword){
>>$this->word=$getword;
>>   }
>>   public function buff(){
>>mail("[EMAIL PROTECTED]","test","test");
>>   }
>> }
>> ?>
>> --
>>
>> --b.php
>> >  function __autoload($class_name) {
>>  include_once $class_name . '.php';
>>  }
>>
>>
>> $objref=new My("Good");
>> $objref->buff();
>> ?>
>> 
>>
>> --c.php--
>> >  function __autoload($class_name) {
>>  include_once $class_name . '.php';
>>  }
>>
>> $obj=new My("Hello");
>> $obj->buff();
>> --
>>
>>
>> That is what I want to try.
>>
>> When c.php run, Mail() function run // < it is OK
>> When b.php run, it also run Mail() fuction. // it is NOT OK
>>
>> I would like to run Mail() function one time only from c.php.
>> However I also get prameter which declare "Good" in b.php
>>
>> Now when c.php and b.php run, the program send twice email. That is  not
>> good!!
>> I would like to run c.php and b.php, then the program, which is Mail()
>> function, get one email and get  "Good"  from b.php
>>
>>
>> Regards,
>> Yui
>>
>
> You could add a parameter to the buff() method.
>
>  Class My{
>private $word;
>function __construct($getword){
> $this->word=$getword;
>}
>public function buff($sendMail = false){
> if ($sendMail) {
> mail("[EMAIL PROTECTED]","test","test");
> }
>}
>  }
>
> When executing b.php pass true too the buff() method to send
> an email.
>
>  --b.php
> function __autoload($class_name) {
>   include_once $class_name . '.php';
>   }
>
>
>  $objref=new My("Good");
>  $objref->buff(true);
>  ?>
>  
>
> When executing c.php don't pass a parameter to the buff() method. So it
> defaults to false. And will not send an email.
>
>  --c.php--
> function __autoload($class_name) {
>   include_once $class_name . '.php';
>   }
>
>  $obj=new My("Hello");
>  $obj->buff();
>  --
>
> --
> 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] Avoid object twice

2008-06-04 Thread Boyd, Todd M.
> Thank you for your advice me!
> 
> -My.php---
>  
> Class My{
>private $word;
>function __construct($getword){
> $this->word=$getword;
>}
>public function buff(){
> mail("[EMAIL PROTECTED]","test","test");
>}
> }
> ?>
> --
> 
> --b.php
>function __autoload($class_name) {
>   include_once $class_name . '.php';
>   }
> 
> 
> $objref=new My("Good");
> $objref->buff();
> ?>
> 
> 
> --c.php--
>function __autoload($class_name) {
>   include_once $class_name . '.php';
>   }
> 
> $obj=new My("Hello");
> $obj->buff();
> --
> 
> That is what I want to try.
> 
> When c.php run, Mail() function run // < it is OK
> When b.php run, it also run Mail() fuction. // it is NOT OK
> 
> I would like to run Mail() function one time only from c.php.
> However I also get prameter which declare "Good" in b.php
> 
> Now when c.php and b.php run, the program send twice email. That is
not
> good!!
> I would like to run c.php and b.php, then the program, which is Mail()
> function, get one email and get  "Good"  from b.php

You are not making any sense... if you only want the Mail() function to
run once, then ONLY CALL ->BUFF() ONE TIME. It's that simple. You are
mailing twice because you call buff() in two separate places--and buff()
in turn calls Mail(). I don't understand your problem.

$objref = new My("Good");
$obj = new My("Hello");
$obj->buff();

Bam. You get Hello, Good, and it sends one e-mail. Since you are
completely abstracting your code from its real-world application, that's
the best I can do.


Todd Boyd
Web Programmer




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



[Fwd: Re: [PHP] multithreading]

2008-06-04 Thread Aschwin Wesselius


hce wrote:

Hi,

1. Does PHP support multithreading?
Yes, it does. I suspect a reply from Manuel Lemos about a multithreading 
class on www.phpclasses.org at any time now.;-)


No kidding, I've tested a class from phpclasses.org and it worked. Can't 
find the library on my computer(s) right now, so I can't give you the 
exact name of the package..


--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other'/


Re: [PHP] multithreading

2008-06-04 Thread Bojan Tesanovic

Hey Jim,
for what do you need multithreading  there can be
some way to do some "multithreading"  in PHP via some
"hacks"

On Jun 4, 2008, at 1:57 PM, hce wrote:


Hi,

1. Does PHP support multithreading?

2. When using PHP to access MySQL, does PHP implents a single thread
or multithread with MySQL?

Thank you.

Jim

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



Bojan Tesanovic
http://www.carster.us/






Re: [PHP] slowness mystery

2008-06-04 Thread Eric Butera
On Wed, Jun 4, 2008 at 8:45 AM, Rene Veerman <[EMAIL PROTECTED]> wrote:
> Ok, i changed from reading from the database to reading from a file.
> It now clocks at 3.37seconds for the malignant peace of javascript..
> Still too slow :(
>
> Timing the readfile statement that outputs the cache file, is at 0.00109
> seconds according to a measurement done with microtime()
> It seems that this is not correct, because if i remove the readfile
> statement, things speed up to 120 milliseconds (from 3.37seconds)..



Make it write out a static .js file and link to that.  Apache can
serve up files like that way faster directly than piping it through
php.  If you don't want to go through that hassle, make sure you have
a far future expire header on the file so that the client does not
request it each time.


See look at this example script named testjs.php:



Here is hitting the php script:
$ ab -n 500 -c 50 http://localhost/testjs/testjs.php

Document Path:  /testjs/testjs.php
Document Length:31068 bytes

Concurrency Level:  50
Time taken for tests:   4.886 seconds
Complete requests:  500
Failed requests:0
Broken pipe errors: 0
Total transferred:  15795390 bytes
HTML transferred:   15689340 bytes
Requests per second:102.33 [#/sec] (mean)
Time per request:   488.60 [ms] (mean)
Time per request:   9.77 [ms] (mean, across all concurrent requests)
Transfer rate:  3232.79 [Kbytes/sec] received


Now hitting the JS directly:
$ ab -n 500 -c 50 http://localhost/testjs/yahoo-dom-event.js

Document Path:  /testjs/yahoo-dom-event.js
Document Length:31068 bytes

Concurrency Level:  50
Time taken for tests:   0.925 seconds
Complete requests:  500
Failed requests:0
Broken pipe errors: 0
Total transferred:  15992720 bytes
HTML transferred:   15831764 bytes
Requests per second:540.54 [#/sec] (mean)
Time per request:   92.50 [ms] (mean)
Time per request:   1.85 [ms] (mean, across all concurrent requests)
Transfer rate:  17289.43 [Kbytes/sec] received


I could go from ~100 requests per second to ~500 requests per second
by hitting a js file directly.

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



Re: [PHP] slowness mystery

2008-06-04 Thread Rene Veerman
Ok, i changed from reading from the database to reading from a file.
It now clocks at 3.37seconds for the malignant peace of javascript..
Still too slow :(

Timing the readfile statement that outputs the cache file, is at 0.00109
seconds according to a measurement done with microtime()
It seems that this is not correct, because if i remove the readfile
statement, things speed up to 120 milliseconds (from 3.37seconds)..

Some more help would be greatly appreciated..

On Wed, Jun 4, 2008 at 9:20 AM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:

> On Wed, Jun 4, 2008 at 3:05 AM, Rene Veerman <[EMAIL PROTECTED]> wrote:
>
>> Hi..
>>
>> I've built a cms that's running into a serious speedbump.
>> I load several sets of javascript through a custom built db
>> caching&compression system.
>> Loading it without caching and compression takes between 2 and 3 seconds
>> for
>> the entire app, 112Kb javascript.
>>
>> The caching system first compresses/obfusicates the requested
>> source-files,
>> then gzcompress()es that and stores the result in my database.
>>
>> The next time the page is requested, the caching system detects the cached
>> copy, and outputs that with an echo statement.
>>
>> One of these code bundles that i request takes over 6 full seconds to
>> load.
>> It's the same 122Kb obfusi-compressed to 52Kb.
>> Even without obfusication, it takes 6 seconds to load when taken from the
>> database.
>> So it's not the browser being slow in parsing the obfusicated code.
>> Firebug's "net"-tab shows this one snippet taking 6 seconds. I don't know
>> exactly what that measures, just the transit time i hope..
>>
>> I suspected the database query, but retrieval takes less than a
>> millisecond.
>> So does the 'echo' statement that outputs it.
>>
>> I'm really puzzled as to what can cause such a delay.
>>
>
> i think putting the js in the database at all, and then using php to
> retrieve it is unnecessary overhead.  i would put the cached contents on
> disc, and refer browsers to a direct url.  maybe you could just put the
> contents of one of your compressed files on disc, and request it from the
> browser, time that, and see if it gets you anywhere.
>
> also, i would check into some of the resources yahoo has in this dept.  for
> example, the ySlow firebug plugin,
>
> http://developer.yahoo.com/yslow/
> there are additional resources as well, and they even have a really slick
> js compressor, freely available.  its so slick in fact, that it will reduce
> the length of variable identifiers that are safe to do on because those
> variables happen to be closures.  neat stuff.
>
> -nathan
>


Re: [PHP] Avoid object twice

2008-06-04 Thread Thijs Lensselink

Quoting Yui Hiroaki <[EMAIL PROTECTED]>:


Thank you for your advice me!



-My.php---
word=$getword;
   }
   public function buff(){
mail("[EMAIL PROTECTED]","test","test");
   }
}
?>
--

--b.php
buff();
?>


--c.php--
buff();
--


That is what I want to try.

When c.php run, Mail() function run // < it is OK
When b.php run, it also run Mail() fuction. // it is NOT OK

I would like to run Mail() function one time only from c.php.
However I also get prameter which declare "Good" in b.php

Now when c.php and b.php run, the program send twice email. That is   
not good!!

I would like to run c.php and b.php, then the program, which is Mail()
function, get one email and get  "Good"  from b.php


Regards,
Yui



You could add a parameter to the buff() method.

 Class My{
private $word;
function __construct($getword){
 $this->word=$getword;
}
public function buff($sendMail = false){
 if ($sendMail) {
 mail("[EMAIL PROTECTED]","test","test");
 }
}
 }

When executing b.php pass true too the buff() method to send
an email.

 --b.php
 buff(true);
 ?>
 

When executing c.php don't pass a parameter to the buff() method. So  
it defaults to false. And will not send an email.


 --c.php--
 buff();
 --

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



Re: [PHP] multithreading

2008-06-04 Thread Per Jessen
hce wrote:

> Hi,
> 
> 1. Does PHP support multithreading?
> 

Not really, no.  If you genuinely need multi-threading, use C or C++.

> 2. When using PHP to access MySQL, does PHP implents a single thread
> or multithread with MySQL?

Single thread. 


/Per Jessen, Zürich


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



Re: [PHP] multithreading

2008-06-04 Thread Wolf
 hce <[EMAIL PROTECTED]> wrote: 
> Hi,
> 
> 1. Does PHP support multithreading?
Depends


> 2. When using PHP to access MySQL, does PHP implents a single thread
> or multithread with MySQL?
Depends

STFW and RTFM

Here's some basics to get you started: 
http://www.google.com/search?q=PHP%3A+Multithreading&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a

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



[PHP] multithreading

2008-06-04 Thread hce
Hi,

1. Does PHP support multithreading?

2. When using PHP to access MySQL, does PHP implents a single thread
or multithread with MySQL?

Thank you.

Jim

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



RE: [PHP] Problem with script timing out in php 4.4.8

2008-06-04 Thread Arno Kuhl
The fact that 59 seconds worked suggested the ini settings was in effect,
otherwise it would have timed out after 30 seconds (default ini setting).
But I also tested your suggestion:

Test timeout - sleep for $t seconds";
echo "max execution time set to ".ini_get("max_execution_time")."";
echo "sleeping ".date('h:i:s')."";
sleep($t);
echo "stop sleeping ".date('h:i:s'); ?>
?>

Same result, $t=59 works but $t=70 times out

Cheers
Arno

-Original Message-
From: Ólafur Waage [mailto:[EMAIL PROTECTED]
Sent: 04 June 2008 11:19
To: php-general@lists.php.net
Subject: Re: [PHP] Problem with script timing out in php 4.4.8

Could you try setting the max_execution_time with ini_set and confirming the
status of it with ini_get ?

- Waage

2008/6/4 Arno Kuhl <[EMAIL PROTECTED]>:
> I recently picked up an issue when I upgraded my IDE, where the
> browser window timed out while I was debugging the code. I checked
> with support and was told the problem was with php 4.4.8 which they'd
> upgraded to, so to confirm I installed 4.4.8 and ran a test - and it
> seems there is a problem with 4.4.8.
>
> The test was:
>
> change max_execution_time from 30 to 600 in php.ini - phpinfo confirms
> max_execution_time=600
>
>  $t=70;
> echo "Test timeout - sleep for $t seconds"; echo "sleeping
> ".date('h:i:s').""; sleep($t); echo "stop sleeping
> ".date('h:i:s'); ?>
>
> $t=59 works fine, but $t=70 times out.
>
> (Windows 2000, Apache Release 10324100)
>
> I ran the same test successfully with $t=500 seconds on a different
> machine running php 4.3.4, everything else the same as the original test
pc.
>
> What bothers me a bit is 4.4.8 has been available since February and
> checking the archives I see no-one else has reported this problem,
> which seems highly unlikely, so I'm wondering if this is specific only
> to my environment somehow. Has anyone else had problems with
> max_execution_time in 4.4.8?
>
> Cheers
> Arno
>
>
> --
> 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





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



Re: [PHP] Problem with script timing out in php 4.4.8

2008-06-04 Thread Ólafur Waage
Could you try setting the max_execution_time with ini_set and
confirming the status of it with ini_get ?

- Waage

2008/6/4 Arno Kuhl <[EMAIL PROTECTED]>:
> I recently picked up an issue when I upgraded my IDE, where the browser
> window timed out while I was debugging the code. I checked with support and
> was told the problem was with php 4.4.8 which they'd upgraded to, so to
> confirm I installed 4.4.8 and ran a test - and it seems there is a problem
> with 4.4.8.
>
> The test was:
>
> change max_execution_time from 30 to 600 in php.ini - phpinfo confirms
> max_execution_time=600
>
>  $t=70;
> echo "Test timeout - sleep for $t seconds";
> echo "sleeping ".date('h:i:s')."";
> sleep($t);
> echo "stop sleeping ".date('h:i:s');
> ?>
>
> $t=59 works fine, but $t=70 times out.
>
> (Windows 2000, Apache Release 10324100)
>
> I ran the same test successfully with $t=500 seconds on a different machine
> running php 4.3.4, everything else the same as the original test pc.
>
> What bothers me a bit is 4.4.8 has been available since February and
> checking the archives I see no-one else has reported this problem, which
> seems highly unlikely, so I'm wondering if this is specific only to my
> environment somehow. Has anyone else had problems with max_execution_time in
> 4.4.8?
>
> Cheers
> Arno
>
>
> --
> 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



[PHP] Problem with script timing out in php 4.4.8

2008-06-04 Thread Arno Kuhl
I recently picked up an issue when I upgraded my IDE, where the browser
window timed out while I was debugging the code. I checked with support and
was told the problem was with php 4.4.8 which they'd upgraded to, so to
confirm I installed 4.4.8 and ran a test - and it seems there is a problem
with 4.4.8.

The test was:

change max_execution_time from 30 to 600 in php.ini - phpinfo confirms
max_execution_time=600

Test timeout - sleep for $t seconds"; 
echo "sleeping ".date('h:i:s').""; 
sleep($t); 
echo "stop sleeping ".date('h:i:s'); 
?> 

$t=59 works fine, but $t=70 times out.

(Windows 2000, Apache Release 10324100)

I ran the same test successfully with $t=500 seconds on a different machine
running php 4.3.4, everything else the same as the original test pc.

What bothers me a bit is 4.4.8 has been available since February and
checking the archives I see no-one else has reported this problem, which
seems highly unlikely, so I'm wondering if this is specific only to my
environment somehow. Has anyone else had problems with max_execution_time in
4.4.8?

Cheers
Arno


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



Re: [PHP] Avoid object twice

2008-06-04 Thread Yui Hiroaki
Thank you for your advice me!



-My.php---
word=$getword;
   }
   public function buff(){
mail("[EMAIL PROTECTED]","test","test");
   }
}
?>
--

--b.php
buff();
?>


--c.php--
buff();
--


That is what I want to try.

When c.php run, Mail() function run // < it is OK
When b.php run, it also run Mail() fuction. // it is NOT OK

I would like to run Mail() function one time only from c.php.
However I also get prameter which declare "Good" in b.php

Now when c.php and b.php run, the program send twice email. That is not good!!
I would like to run c.php and b.php, then the program, which is Mail()
function, get one email and get  "Good"  from b.php


Regards,
Yui

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



[PHP] Re: APC + PHP Problem (apc_fcntl_lock failed: Bad file descriptor)

2008-06-04 Thread Colin Guthrie

Scott McNaught [Synergy 8] wrote:
Thanks for your reply.  I will try upgrading it. 


If anyone else has experienced this problem, please let me know.


Something else to note, I'm using pthread locking. I read about various 
things and looked a presentation from Facebook's use of APC and the fact 
they use pthread locks... I figured if it's good enough for them ;)


Not had any problems yet touch wood!

If you use the Fedora SRPM build of APC then it only compiles one 
option. The Mandriva package is way nicer and compiles several copies of 
the shared library for the different locking mechanisms allowing you to 
switch easily without recompilation. I hacked up the fedora SRPM for my 
own use on my CentOS servers  the tasty flavours of linux :D


Col


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



Re: [PHP] Avoid object twice

2008-06-04 Thread Yui Hiroaki
Thank you for your advice me!



-My.php---
word=$getword;
   }
   public function buff(){
mail("[EMAIL PROTECTED]","test","test");
   }
}
?>
--

--b.php
buff();
?>


--c.php--
buff();
--


That is what I want to try.

When c.php run, Mail() function run // < it is OK
When b.php run, it also run Mail() fuction. // it is NOT OK

I would like to run Mail() function one time only from c.php.
However I also get prameter which declare "Good" in b.php

Now when c.php and b.php run, the program send twice email. That is not good!!
I would like to run c.php and b.php, then the program, which is Mail()
function, get one email and get  "Good"  from b.php


Regards,
Yui

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



Re: [PHP] slowness mystery

2008-06-04 Thread Nathan Nobbe
On Wed, Jun 4, 2008 at 3:05 AM, Rene Veerman <[EMAIL PROTECTED]> wrote:

> Hi..
>
> I've built a cms that's running into a serious speedbump.
> I load several sets of javascript through a custom built db
> caching&compression system.
> Loading it without caching and compression takes between 2 and 3 seconds
> for
> the entire app, 112Kb javascript.
>
> The caching system first compresses/obfusicates the requested source-files,
> then gzcompress()es that and stores the result in my database.
>
> The next time the page is requested, the caching system detects the cached
> copy, and outputs that with an echo statement.
>
> One of these code bundles that i request takes over 6 full seconds to load.
> It's the same 122Kb obfusi-compressed to 52Kb.
> Even without obfusication, it takes 6 seconds to load when taken from the
> database.
> So it's not the browser being slow in parsing the obfusicated code.
> Firebug's "net"-tab shows this one snippet taking 6 seconds. I don't know
> exactly what that measures, just the transit time i hope..
>
> I suspected the database query, but retrieval takes less than a
> millisecond.
> So does the 'echo' statement that outputs it.
>
> I'm really puzzled as to what can cause such a delay.
>

i think putting the js in the database at all, and then using php to
retrieve it is unnecessary overhead.  i would put the cached contents on
disc, and refer browsers to a direct url.  maybe you could just put the
contents of one of your compressed files on disc, and request it from the
browser, time that, and see if it gets you anywhere.

also, i would check into some of the resources yahoo has in this dept.  for
example, the ySlow firebug plugin,

http://developer.yahoo.com/yslow/
there are additional resources as well, and they even have a really slick js
compressor, freely available.  its so slick in fact, that it will reduce the
length of variable identifiers that are safe to do on because those
variables happen to be closures.  neat stuff.

-nathan


[PHP] slowness mystery

2008-06-04 Thread Rene Veerman
Hi..

I've built a cms that's running into a serious speedbump.
I load several sets of javascript through a custom built db
caching&compression system.
Loading it without caching and compression takes between 2 and 3 seconds for
the entire app, 112Kb javascript.

The caching system first compresses/obfusicates the requested source-files,
then gzcompress()es that and stores the result in my database.

The next time the page is requested, the caching system detects the cached
copy, and outputs that with an echo statement.

One of these code bundles that i request takes over 6 full seconds to load.
It's the same 122Kb obfusi-compressed to 52Kb.
Even without obfusication, it takes 6 seconds to load when taken from the
database.
So it's not the browser being slow in parsing the obfusicated code.
Firebug's "net"-tab shows this one snippet taking 6 seconds. I don't know
exactly what that measures, just the transit time i hope..

I suspected the database query, but retrieval takes less than a millisecond.
So does the 'echo' statement that outputs it.

I'm really puzzled as to what can cause such a delay.