php-general Digest 18 May 2011 14:16:52 -0000 Issue 7316

Topics (messages 312850 through 312865):

Re: An Invitation to Neuroscientists and Physicists: Singapore Citizen Mr. Teo 
En Ming (Zhang Enming) Reports First Hand Account of Mind Intrusion and Mind 
Reading
        312850 by: Daniel Brown

Re: Explode Question
        312851 by: Marc Guay
        312852 by: admin.buskirkgraphics.com
        312853 by: James Yerge
        312855 by: James Yerge
        312856 by: admin.buskirkgraphics.com
        312857 by: James Yerge

Friday Preview
        312854 by: Daniel Brown
        312858 by: Mike Mackintosh

Re: Session question
        312859 by: Ross Hansen
        312860 by: admin.buskirkgraphics.com

Sending Email via  SMTP account using PHP
        312861 by: Eli Orr (Office)

Re: Bitwise AND for 31-st bit
        312862 by: Vitalii Demianets

Re: NOMAIL option for the list?
        312863 by: Per Jessen

observer pattern
        312864 by: Ken Guest

Sending messages from php to C++ application via UDP socket
        312865 by: Schlager, Christian

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
On Tue, May 17, 2011 at 18:51, HallMarc Websites
<[email protected]> wrote:
> My concern is with the admission of belonging to 137 mailing lists! Where do 
> you find the time?

    Actually, I just looked, and I am subscribed to 114 lists, and
that's after a mass-unsubscription of all but one of the Mozilla lists
when I left the project, as well as the Apache lists and kernel
discussions.  The remaining lists are those which I am either
regularly active (read: at least once a fortnight) or I monitor on a
daily or near-daily basis.  So I don't think Michelle is crazy (for
that, anyway ;-P).

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

--- End Message ---
--- Begin Message ---
> $one = array(0 =>'golf', 1 => 'field');
> $two = array(0 => "On the golf course or in the field of clover");
> $array_exp = explode($one, $two);

What's the desired result?

array('golf' => "On the golf course or in the field of clover",
'field' =>  "On the golf course or in the field of clover")); ?


Marc

--- End Message ---
--- Begin Message ---
The desired result is.

Array
(
        [0] = > "On the";
        [1] = > "course or in the";
        [2] = > "of colver";
);

I am just not sure the delimiter can be an array in the Explode function.






Richard L. Buskirk

-----Original Message-----
From: Marc Guay [mailto:[email protected]] 
Sent: Tuesday, May 17, 2011 7:52 PM
To: [email protected]
Subject: Re: [PHP] Explode Question

> $one = array(0 =>'golf', 1 => 'field');
> $two = array(0 => "On the golf course or in the field of clover");
> $array_exp = explode($one, $two);

What's the desired result?

array('golf' => "On the golf course or in the field of clover",
'field' =>  "On the golf course or in the field of clover")); ?


Marc

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


--- End Message ---
--- Begin Message ---
On 05/17/2011 07:53 PM, [email protected] wrote:
> The desired result is.
>
> Array
> (
>       [0] = > "On the";
>       [1] = > "course or in the";
>       [2] = > "of colver";
> );
>
> I am just not sure the delimiter can be an array in the Explode function.
>
>
>
>
>
>
> Richard L. Buskirk
>
> -----Original Message-----
> From: Marc Guay [mailto:[email protected]] 
> Sent: Tuesday, May 17, 2011 7:52 PM
> To: [email protected]
> Subject: Re: [PHP] Explode Question
>
>> $one = array(0 =>'golf', 1 => 'field');
>> $two = array(0 => "On the golf course or in the field of clover");
>> $array_exp = explode($one, $two);
> What's the desired result?
>
> array('golf' => "On the golf course or in the field of clover",
> 'field' =>  "On the golf course or in the field of clover")); ?
>
>
> Marc
>

explode() takes three parameters; string, string, [int]. Where [int] is
optional.

Ex:
$ipList = '192.168.1.0,192.168.1.1,192.168.1.2';
$ipList = explode(',',$ipList);

Returns an array of strings:

Array
(
[0] => 192.168.1.0,
[1] => 192.168.1.1,
[2] => 192.168.1.2
);



--- End Message ---
--- Begin Message ---
On 05/17/2011 07:53 PM, [email protected] wrote:
> The desired result is.
>
> Array
> (
>       [0] = > "On the";
>       [1] = > "course or in the";
>       [2] = > "of colver";
> );
>
> I am just not sure the delimiter can be an array in the Explode function.
>
>
>
>
>
>
> Richard L. Buskirk
>
> -----Original Message-----
> From: Marc Guay [mailto:[email protected]] 
> Sent: Tuesday, May 17, 2011 7:52 PM
> To: [email protected]
> Subject: Re: [PHP] Explode Question
>
>> $one = array(0 =>'golf', 1 => 'field');
>> $two = array(0 => "On the golf course or in the field of clover");
>> $array_exp = explode($one, $two);
> What's the desired result?
>
> array('golf' => "On the golf course or in the field of clover",
> 'field' =>  "On the golf course or in the field of clover")); ?
>
>
> Marc
>

Here's something to mess around with, to fit to your liking.

<?php
$one = array('golf','field');
$two = array("On the golf course or in the field of clover");
$result = array_explode($one,$two);

print_r($result);

function array_explode($delimiters,$array)
{
    if ( !is_array($delimiters) || !is_array($array) ) {
        //bail
        return;
    }
    $string = $array[0];
    $regex = "@(".implode('|',$delimiters).")@";
    return preg_split($regex,$string);
}
?>

--- End Message ---
--- Begin Message ---
That is exactly it.
Thanks James I knew it was simple just forgot how it was done.





Richard L. Buskirk

-----Original Message-----
From: James Yerge [mailto:[email protected]] 
Sent: Tuesday, May 17, 2011 8:51 PM
To: [email protected]
Cc: 'Marc Guay'; [email protected]
Subject: Re: [PHP] Explode Question

On 05/17/2011 07:53 PM, [email protected] wrote:
> The desired result is.
>
> Array
> (
>       [0] = > "On the";
>       [1] = > "course or in the";
>       [2] = > "of colver";
> );
>
> I am just not sure the delimiter can be an array in the Explode function.
>
>
>
>
>
>
> Richard L. Buskirk
>
> -----Original Message-----
> From: Marc Guay [mailto:[email protected]] 
> Sent: Tuesday, May 17, 2011 7:52 PM
> To: [email protected]
> Subject: Re: [PHP] Explode Question
>
>> $one = array(0 =>'golf', 1 => 'field');
>> $two = array(0 => "On the golf course or in the field of clover");
>> $array_exp = explode($one, $two);
> What's the desired result?
>
> array('golf' => "On the golf course or in the field of clover",
> 'field' =>  "On the golf course or in the field of clover")); ?
>
>
> Marc
>

Here's something to mess around with, to fit to your liking.

<?php
$one = array('golf','field');
$two = array("On the golf course or in the field of clover");
$result = array_explode($one,$two);

print_r($result);

function array_explode($delimiters,$array)
{
    if ( !is_array($delimiters) || !is_array($array) ) {
        //bail
        return;
    }
    $string = $array[0];
    $regex = "@(".implode('|',$delimiters).")@";
    return preg_split($regex,$string);
}
?>


--- End Message ---
--- Begin Message ---
On 05/17/2011 09:09 PM, [email protected] wrote:
> That is exactly it.
> Thanks James I knew it was simple just forgot how it was done.
>
>
>
>
>
> Richard L. Buskirk
>
> -----Original Message-----
> From: James Yerge [mailto:[email protected]] 
> Sent: Tuesday, May 17, 2011 8:51 PM
> To: [email protected]
> Cc: 'Marc Guay'; [email protected]
> Subject: Re: [PHP] Explode Question
>
> On 05/17/2011 07:53 PM, [email protected] wrote:
>> The desired result is.
>>
>> Array
>> (
>>      [0] = > "On the";
>>      [1] = > "course or in the";
>>      [2] = > "of colver";
>> );
>>
>> I am just not sure the delimiter can be an array in the Explode function.
>>
>>
>>
>>
>>
>>
>> Richard L. Buskirk
>>
>> -----Original Message-----
>> From: Marc Guay [mailto:[email protected]] 
>> Sent: Tuesday, May 17, 2011 7:52 PM
>> To: [email protected]
>> Subject: Re: [PHP] Explode Question
>>
>>> $one = array(0 =>'golf', 1 => 'field');
>>> $two = array(0 => "On the golf course or in the field of clover");
>>> $array_exp = explode($one, $two);
>> What's the desired result?
>>
>> array('golf' => "On the golf course or in the field of clover",
>> 'field' =>  "On the golf course or in the field of clover")); ?
>>
>>
>> Marc
>>
> Here's something to mess around with, to fit to your liking.
>
> <?php
> $one = array('golf','field');
> $two = array("On the golf course or in the field of clover");
> $result = array_explode($one,$two);
>
> print_r($result);
>
> function array_explode($delimiters,$array)
> {
>     if ( !is_array($delimiters) || !is_array($array) ) {
>         //bail
>         return;
>     }
>     $string = $array[0];
>     $regex = "@(".implode('|',$delimiters).")@";
>     return preg_split($regex,$string);
> }
> ?>
>
>
>

Not a problem, glad to be of help.


--- End Message ---
--- Begin Message ---
    Hey, folks;

    To try to boost a bit of creative thinking and increase list
traffic a bit, let's reach back into the past this Friday and bring
back an oldie-but-goodie:

        PHP Brainteasers

    The old-heads on the list may remember how, a few years ago, we
had a rather long group of threads where we would express common
phrases (in English --- sorry to the non-native-speakers) in PHP code.
 For those who weren't around or don't recall, here's a very, very
basic example:

<?php
        class proverb {

            var $amount;

            function give() {
                return ++$this->amount;
            }

            function receive() {
                return --$this->amount;
            }

            function steal() {
                return $this->amount = 0;
            }

            function tally() {
                return $this->amount;
            }

            function proverb($amount) {
                $this->amount = $amount;
            }
        }

        $p = new proverb(5);

        if ($p->give() > $p->receive()) {
            echo '\'Tis.'.PHP_EOL;
        } else {
            echo 'Give me '.$p->amount.'.'.PHP_EOL;
        }
?>

    Here are the details:

        1.) While it doesn't have to "do" anything necessarily, it
must compile without ANY errors, warnings, or variable notices (other
notices, such as timezone settings, are okay).
        2.) It can be for any version of PHP5 --- legacy code for PHP
< 5.0.0 is not eligible.
        3.) Feel free to use little-known functions, variable
declaration/modification techniques, et cetera.
        4.) Obfuscation does not always count as a brainteaser.
        5.) You may use variable and function names as hints.
        6.) Try to employ at least the basics of code standards and
best practices that should be common sense to all PHP developers.

    The hope is that, with several people participating, newbies and
experts alike will be able to say, "hey, I never thought of doing it
that way!" or, "wow, I didn't even know PHP had that functionality
built-in!" while also achieving the goals mentioned earlier.

    Hope to see a good amount of participation.  Remember, wait until
Friday (in your time zone!).  If you come up with some in the
meantime, just hold onto them until then; there's no limit to the
amount of submissions anyone can send.  In fact, the more we get, the
more fun it should be for those who participate.

    One final note --- whomever starts the thread on Friday, please
use the following subject, verbatim:

        PHP Brainteasers 2011

    This way, folks who don't want to be involved can't just filter
that thread out and not be bombarded.

    Thanks, all.  Looking forward to seeing what everyone invents and
puzzling over them myself!

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

--- End Message ---
--- Begin Message ---
Great Idea, and I cant wait!

On May 17, 2011, at 8:28 PM, Daniel Brown wrote:

>    Hey, folks;
> 
>    To try to boost a bit of creative thinking and increase list
> traffic a bit, let's reach back into the past this Friday and bring
> back an oldie-but-goodie:
> 
>        PHP Brainteasers
> 
>    The old-heads on the list may remember how, a few years ago, we
> had a rather long group of threads where we would express common
> phrases (in English --- sorry to the non-native-speakers) in PHP code.
> For those who weren't around or don't recall, here's a very, very
> basic example:
> 
> <?php
>        class proverb {
> 
>            var $amount;
> 
>            function give() {
>                return ++$this->amount;
>            }
> 
>            function receive() {
>                return --$this->amount;
>            }
> 
>            function steal() {
>                return $this->amount = 0;
>            }
> 
>            function tally() {
>                return $this->amount;
>            }
> 
>            function proverb($amount) {
>                $this->amount = $amount;
>            }
>        }
> 
>        $p = new proverb(5);
> 
>        if ($p->give() > $p->receive()) {
>            echo '\'Tis.'.PHP_EOL;
>        } else {
>            echo 'Give me '.$p->amount.'.'.PHP_EOL;
>        }
> ?>
> 
>    Here are the details:
> 
>        1.) While it doesn't have to "do" anything necessarily, it
> must compile without ANY errors, warnings, or variable notices (other
> notices, such as timezone settings, are okay).
>        2.) It can be for any version of PHP5 --- legacy code for PHP
> < 5.0.0 is not eligible.
>        3.) Feel free to use little-known functions, variable
> declaration/modification techniques, et cetera.
>        4.) Obfuscation does not always count as a brainteaser.
>        5.) You may use variable and function names as hints.
>        6.) Try to employ at least the basics of code standards and
> best practices that should be common sense to all PHP developers.
> 
>    The hope is that, with several people participating, newbies and
> experts alike will be able to say, "hey, I never thought of doing it
> that way!" or, "wow, I didn't even know PHP had that functionality
> built-in!" while also achieving the goals mentioned earlier.
> 
>    Hope to see a good amount of participation.  Remember, wait until
> Friday (in your time zone!).  If you come up with some in the
> meantime, just hold onto them until then; there's no limit to the
> amount of submissions anyone can send.  In fact, the more we get, the
> more fun it should be for those who participate.
> 
>    One final note --- whomever starts the thread on Friday, please
> use the following subject, verbatim:
> 
>        PHP Brainteasers 2011
> 
>    This way, folks who don't want to be involved can't just filter
> that thread out and not be bombarded.
> 
>    Thanks, all.  Looking forward to seeing what everyone invents and
> puzzling over them myself!
> 
> -- 
> </Daniel P. Brown>
> Network Infrastructure Manager
> http://www.php.net/
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


--- End Message ---
--- Begin Message ---
Unless your adding more code to your included file it isn't worth having it as 
an include as there is more typing/text involved. For management purposes also 
it would also look ugly if you were just having one file purely  for 
session_start();

> From: [email protected]
> Date: Tue, 17 May 2011 13:01:19 +0200
> To: [email protected]
> Subject: Re: [PHP] Session question
> 
> Paul Halliday wrote:
> 
> > Is it OK to have session_start as an include?
> > 
> 
> Yes.
> 
> 
> 
> -- 
> Per Jessen, Zürich (18.1°C)
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
                                          

--- End Message ---
--- Begin Message ---
You can have a session start in an htaccess file.


.htaccess

php_value session.auto_start 1



Do not scream at me if you do not like this approach or it does not work for
you.
I use it and it works well for me.

Simply a suggestion.


Richard L. Buskirk


-----Original Message-----
From: Ross Hansen [mailto:[email protected]] 
Sent: Tuesday, May 17, 2011 11:16 PM
To: [email protected]
Subject: RE: [PHP] Session question


Unless your adding more code to your included file it isn't worth having it
as an include as there is more typing/text involved. For management purposes
also it would also look ugly if you were just having one file purely  for
session_start();

> From: [email protected]
> Date: Tue, 17 May 2011 13:01:19 +0200
> To: [email protected]
> Subject: Re: [PHP] Session question
> 
> Paul Halliday wrote:
> 
> > Is it OK to have session_start as an include?
> > 
> 
> Yes.
> 
> 
> 
> -- 
> Per Jessen, Zürich (18.1°C)
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
                                          


--- End Message ---
--- Begin Message ---

Hi,
I'm looking for a good example for using a real SMTP account to send email from, such as [email protected] where there is a user & password and smtp server available.

Please advise with a good example to reuse,

Thanks

Eli

--- End Message ---
--- Begin Message ---
On Tuesday 17 May 2011 22:06:34 David Harkness wrote:
> It appears that PHP is truncating the constant 0x80000000 to be within
> MIN_INT and MAX_INT instead of as a bit field, but when shifting 1 << 31 it
> doesn't do apply any constraints. That's pretty typical of
> bit-manipulation: it will merrily slide 1 bits off either end. This
> explains why & produces 0 as it's doing 0x80000000 & 0x7FFFFFFF. It also
> explains the second tests.

Yes, that's it!
I slightly expanded test output and now it's clear that you are right:

$tst1 = (1 << 31);
$tst2 = 0x80000000;
$tst1_eq = $tst1 & 0x80000000;
$tst2_eq = $tst2 & 0x80000000;
$str1 = sprintf("%1$032b", $tst1);
$str2 = sprintf("%1$032b", $tst2);
print "tst1=$tst1 ($str1), tst1_eq=$tst1_eq, tst1_type=".gettype($tst1)."\n";
print "tst2=$tst2 ($str2), tst2_eq=$tst2_eq, tst2_type=".gettype($tst2)."\n";

produces this output:

tst1=-2147483648 (10000000000000000000000000000000), tst1_eq=0, 
tst1_type=integer
tst2=2147483647 (01111111111111111111111111111111), tst2_eq=2147483647, 
tst2_type=integer

Now it is obvious to me that PHP 5.2 clamps explicit constants to MAX_INT. 
Weird, brrrr...

>
> On 64-bit 5.3.3 I get
>
>     tst1=2147483648, tst1_eq=2147483648, tst1_type=integer
>     tst2=2147483648, tst2_eq=2147483648, tst2_type=integer
>
> If I try the 64-bit-equivalent code I get
>
>     tst1=-9223372036854775808, tst1_eq=-9223372036854775808,
> tst1_type=integer
>     tst2=9.22337203685E+18, tst2_eq=-9223372036854775808, tst2_type=double
>

I get similar results with 5.3 on my amd64 host too. It works as it should, no 
weirdness. Glad to know that 5.3 get it fixed. Pity to me that I can not 
update my 5.2 on ARM board.

-- 
Vitalii Demianets

--- End Message ---
--- Begin Message ---
Michelle Konzack wrote:

> Hello Daniel Brown,
> 
> Am 2011-05-17 13:15:50, hacktest Du folgendes herunter:
>> On Tue, May 17, 2011 at 13:11, Michelle Konzack
>> <[email protected]> wrote:
>> > Is this not longer subscriber only?
>>     Actually, it never has been.  It's subscription to receive, but
>> open to the public for one-off postings.
> 
> Hmmm, when I tried to post to the List without subscribtion, any  of 
> my post where rejected and I had to subscribe...
> 
> Unfortunately the messages are all coming into my CellPhone and  I 
> have to /dev/null it on my server.
> 
> Ist there a way to set my account to NOMAIL option?

Michelle, the list is ezmlm-driven, it should be possible to subscribe
an alias to the list, which means that that address will be allowed to
post, but will not receive any postings. 

Try this address:

[email protected]



-- 
Per Jessen, Zürich (14.7°C)


--- End Message ---
--- Begin Message ---
Lo,

so, I'm wondering - how many of you use the observer pattern in php;
and if so, do you implement it 'standalone' or with the spl classes?
Is there any particular advantage to doing it "your way"; whichever
your way is?

Ken

-- 
http://blogs.linux.ie/kenguest/

--- End Message ---
--- Begin Message ---

Hello,

I am a first-time poster. I hope this is the proper way to ask my question:

I have a C++ media player application that I want to control via a php
website.
To that end the application has an UDP socket listening for Player
messages.
In C++ player messages have the following members:

class MessageHeader
{
        UINT16          packetSize;             // size of message in bytes
including header
        UINT16          sequenceNum;    // sequence number of message
        UINT16          flags;          // flags
        UINT16          msgType;                // msg type
}

class PlayerCommand : public MessageHeader
{
        WCHAR command[MAX_PATH];                // dynamic string
}


The php website is supposed to create an UDP socket in order to send player
commands (play, stop, next, etc.)
However, according to the documentation all php socket functions only take
messages in string format.
For example, int socket_sendto ( resource $socket , string $buf , int $len
, ....


My question is this:
If it is possible at all, how can I create a $buf - string that represents
the PlayerCommand class and is accepted by the C++ listening socket?


Thank you for your time!


Best Regards,
Christian Schlager

Carl Zeiss AG
Standort Jena/Jena location
Geschäftsfeld Planetarien/Planetarium Division
Softwareentwickler/Software developer

Phone : ++49 (3641) 64-2575
e-mail: [email protected]

---------------------------------------- 
This message is intended for a particular addressee only and may contain 
business or company secrets. If you have received this email in error, please 
contact the sender and delete the message immediately. Any use of this email, 
including saving, publishing, copying, replication or forwarding of the message 
or the contents is not permitted.  

--- End Message ---

Reply via email to