php-general Digest 5 Jun 2012 02:40:18 -0000 Issue 7841
Topics (messages 318136 through 318155):
Re:
318136 by: Al
Re: help with preg_match
318137 by: Chris Purves
Re: disabled cookies
318138 by: Lester Caine
318152 by: Paul M Foster
318153 by: Ashley Sheridan
318154 by: Matijn Woudt
Hungarian Notation interest with PHP
318139 by: Mihamina Rakotomandimby
318140 by: Ashley Sheridan
318141 by: Mihamina Rakotomandimby
318142 by: Tony Marston
318143 by: Matijn Woudt
318145 by: Tim Streater
long running php script won't complete :(
318144 by: rene7705
318146 by: Matijn Woudt
0.0.0.0 & iplong()
318147 by: jas
318148 by: Matijn Woudt
318150 by: jas
318151 by: Matijn Woudt
Re: Using default argument values in the middle of the argument list
318149 by: xgondza
zend_auto_global_disable_jit missing in PHP 5.4.5
318155 by: freeone3000
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 6/3/2012 8:26 PM, Chris Purves wrote:
Hello,
I am trying to use preg_match to match something from an html file. Within the
html file is some text that looks like:
<span>Something, something end</span>
I know that the text ends 'end', but I don't know what the Something, something
is. I am using preg_match as follows:
preg_match('/[^>]*end/',$curl_response,$matches);
I want to match 'end' and everything before it that is not '>'.
The problem appears to be with the '>'. I have tried escaping (\>), but it
didn't make a difference. The php script hangs when it tries to run this
function.
You didn't say the phrase is always enclosed in <span> tags; but I assume it is
not. This will handle any tags.
Try this pattern "%<[^>]+>(.+)\s+end\s*</%i" Note the % instead of "/" because
you need it in the pattern. Also, the \s are in case there are extra spaces.
Use print_r on your $matches. If you expect more than one, then use
preg_match_all()
--- End Message ---
--- Begin Message ---
On 2012-06-03 22:37, Robert Williams wrote:
> On Jun 3, 2012, at 17:28, "Chris Purves"<[email protected]> wrote:
>
>> I know that the text ends 'end', but I don't know what the Something,
>> something is. I am using preg_match as follows:
>>
>> preg_match('/[^>]*end/',$curl_response,$matches);
>>
>> I want to match 'end' and everything before it that is not '>'.
>
> You need to match something at the beginning. Try this:
>
> preg_match('/>([^>]*end)/', $curl_response, $matches);
>
> Assuming a match, you can then look to $matches[1] for your content.
>
That did it. In my case, I know that the first letter is capitalized, so I
used:
preg_match('/[A-Z][^>]*end/', $curl_response, $matches);
Thanks for your help.
--
Chris Purves
"The eyes are the groin of the head." Dwight Schrute
--- End Message ---
--- Begin Message ---
Matijn Woudt wrote:
I wonder what browser you're using. I just read the IE10 privacy
policy, and it pretty much states the same, Microsoft can collect
private data from you. Opera, Firefox and Safari probably have
something similar.
Seamonkey ... on Linux
Still prefer a proper internet suit so I can simply open tabs from email links
and compose html in-line as required.
But the point I was making was that I am restricted from linking to Google by my
customers rules as it's considered a 'security risk' to sensitive personal data.
We use OSM nowadays for mapping, and any site search is private to the server,
not using the 'free' search services. If my actions fail a security audit I have
to amend them ...
I had managed to avoid all of the 'social media' services, but am now having to
'participate' simple to check out what cookies they are setting on sites that
are not affected by security restrictions ...
--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php
--- End Message ---
--- Begin Message ---
On Sun, Jun 03, 2012 at 10:21:21PM +0100, Ashley Sheridan wrote:
>
>
> Al <[email protected]> wrote:
>
> >Disabled cookies use to be a problem years ago. What's your
> >experience these days.
> >
> >I need it for my session ID. As I read the docs, the old method of
> >appending it to the URL is a security issue.
> >
> >I can obviously save the ID in a temp file which can be read by all
> >the pages needing it.
> >
> >Al....
> >
> >-- PHP General Mailing List (http://www.php.net/) To unsubscribe,
> >visit: http://www.php.net/unsub.php
>
> There is a new law been passed in the UK that makes non-essential
> cookies opt-in only, so you must get permission in order to use them.
Good lord. I'm glad the U.S. Congress has not gotten together to pass
laws about how we build websites here. I'm not sure I could take
less-than-bright government bureaucrats telling me how to do the job of
programming. No offense, Ash, but you can keep your parliament.
Paul
--
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com
--- End Message ---
--- Begin Message ---
On Mon, 2012-06-04 at 17:53 -0400, Paul M Foster wrote:
> On Sun, Jun 03, 2012 at 10:21:21PM +0100, Ashley Sheridan wrote:
>
> >
> >
> > Al <[email protected]> wrote:
> >
> > >Disabled cookies use to be a problem years ago. What's your
> > >experience these days.
> > >
> > >I need it for my session ID. As I read the docs, the old method of
> > >appending it to the URL is a security issue.
> > >
> > >I can obviously save the ID in a temp file which can be read by all
> > >the pages needing it.
> > >
> > >Al....
> > >
> > >-- PHP General Mailing List (http://www.php.net/) To unsubscribe,
> > >visit: http://www.php.net/unsub.php
> >
> > There is a new law been passed in the UK that makes non-essential
> > cookies opt-in only, so you must get permission in order to use them.
>
> Good lord. I'm glad the U.S. Congress has not gotten together to pass
> laws about how we build websites here. I'm not sure I could take
> less-than-bright government bureaucrats telling me how to do the job of
> programming. No offense, Ash, but you can keep your parliament.
>
> Paul
>
> --
> Paul M. Foster
> http://noferblatz.com
> http://quillandmouse.com
>
Yeah, it's been such a pain, as nobody over here is quite sure how the
hell it'll be enforced either, or if it even will be. It's also pretty
vague as to just where the line gets drawn. The official government
sites on this are pretty black and white, but don't clearly address the
grey areas. I think this is definitely a case of the persons making the
laws don't understand the technology involved, which sadly seems to be
the case across a lot of tech laws being passed world-wide of late :(
--
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On Tue, Jun 5, 2012 at 12:13 AM, Ashley Sheridan
<[email protected]> wrote:
> On Mon, 2012-06-04 at 17:53 -0400, Paul M Foster wrote:
>
>> On Sun, Jun 03, 2012 at 10:21:21PM +0100, Ashley Sheridan wrote:
>>
>> >
>> >
>> > Al <[email protected]> wrote:
>> >
>> > >Disabled cookies use to be a problem years ago. What's your
>> > >experience these days.
>> > >
>> > >I need it for my session ID. As I read the docs, the old method of
>> > >appending it to the URL is a security issue.
>> > >
>> > >I can obviously save the ID in a temp file which can be read by all
>> > >the pages needing it.
>> > >
>> > >Al....
>> > >
>> > >-- PHP General Mailing List (http://www.php.net/) To unsubscribe,
>> > >visit: http://www.php.net/unsub.php
>> >
>> > There is a new law been passed in the UK that makes non-essential
>> > cookies opt-in only, so you must get permission in order to use them.
>>
>> Good lord. I'm glad the U.S. Congress has not gotten together to pass
>> laws about how we build websites here. I'm not sure I could take
>> less-than-bright government bureaucrats telling me how to do the job of
>> programming. No offense, Ash, but you can keep your parliament.
>>
>> Paul
>>
>> --
>> Paul M. Foster
>> http://noferblatz.com
>> http://quillandmouse.com
>>
>
>
> Yeah, it's been such a pain, as nobody over here is quite sure how the
> hell it'll be enforced either, or if it even will be. It's also pretty
> vague as to just where the line gets drawn. The official government
> sites on this are pretty black and white, but don't clearly address the
> grey areas. I think this is definitely a case of the persons making the
> laws don't understand the technology involved, which sadly seems to be
> the case across a lot of tech laws being passed world-wide of late :(
>
Yep, When this law was discussed, they were mostly talking about
completely banning cookies. Only later they figured out that there are
quite a few sites that can't live without cookies...
- Matijn
--- End Message ---
--- Begin Message ---
Hi all,
I have a colleague stuck with this thing named "Hungarian Notation"
http://goo.gl/xYv8O
We try to define our internal coding standards, which is very close to
the Symfony ones http://goo.gl/f2rcO
But we're in conflict because the colleague really argue about his
"Hungarian Notation".
Have you got some ressources arguing against this? I ran out of mine to
convince him...
--
RMA.
--- End Message ---
--- Begin Message ---
Mihamina Rakotomandimby <[email protected]> wrote:
>Hi all,
>
>I have a colleague stuck with this thing named "Hungarian Notation"
>http://goo.gl/xYv8O
>
>We try to define our internal coding standards, which is very close to
>the Symfony ones http://goo.gl/f2rcO
>
>But we're in conflict because the colleague really argue about his
>"Hungarian Notation".
>
>Have you got some ressources arguing against this? I ran out of mine to
>
>convince him...
>
>--
>RMA.
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
The two don't look to be mutually exclusive, but Hungarian notation doesn't
make much sense to me for php. Php is a loose typed language, and variables can
(and do) change their types often. Consider even the internal php functions
which can return booleans, or arrays or strings, all from the same function.
Using Hungarian notation to give the dev a hint about the various types doesn't
make much sense, and may give the dev a false sense of security.
Thanks,
Ash
http://ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On 06/04/2012 05:58 PM, Ashley Sheridan wrote:
The two don't look to be mutually exclusive,
Sure, they're not.
It's not forbiden to "prefix" variables.
but Hungarian notation
doesn't make much sense to me for php. Php is a loose typed language,
That's the first point I told him. No way: for him it's syntaxically
compliant.
:-)
--
RMA.
--- End Message ---
--- Begin Message ---
"Mihamina Rakotomandimby" wrote in message
news:[email protected]...
Hi all,
I have a colleague stuck with this thing named "Hungarian Notation"
http://goo.gl/xYv8O
We try to define our internal coding standards, which is very close to the
Symfony ones http://goo.gl/f2rcO
But we're in conflict because the colleague really argue about his
"Hungarian Notation".
Have you got some ressources arguing against this? I ran out of mine to
convince him...
Take a look at http://en.wikipedia.org/wiki/Hungarian_notation which shows
that quite a few 'big' names are against it.
I personally hate it because it ties a variable to a particular type, which
in PHP is useless as a variable is allowed to change its type 'on the fly'.
Even in a strongly typed language it can cause problems - I remember many
years ago having a variable called $numCustomerId because CustomerId was
supposed to be numeric. Then it transpired that it could actually contain
alpha characters, so it had to be a string and not a number. Changing all
occurrences of $numCustomerId to $strCustomerId was a royal PITA, but it
would have been totally confusing to allow alpha characters in a variable
that was supposed to contain nothing but numbers.
--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
--- End Message ---
--- Begin Message ---
On Mon, Jun 4, 2012 at 4:43 PM, Mihamina Rakotomandimby
<[email protected]> wrote:
> Hi all,
>
> I have a colleague stuck with this thing named "Hungarian Notation"
> http://goo.gl/xYv8O
>
> We try to define our internal coding standards, which is very close to the
> Symfony ones http://goo.gl/f2rcO
>
> But we're in conflict because the colleague really argue about his
> "Hungarian Notation".
>
> Have you got some ressources arguing against this? I ran out of mine to
> convince him...
>
Hungarion notation just doesn't make sense in PHP. You should not even
try to convince him, if he doesn't understand this, then you might be
better off finding another colleague ;)
--- End Message ---
--- Begin Message ---
On 04 Jun 2012 at 15:43, Mihamina Rakotomandimby <[email protected]> wrote:
> I have a colleague stuck with this thing named "Hungarian Notation"
> http://goo.gl/xYv8O
>
> We try to define our internal coding standards, which is very close to
> the Symfony ones http://goo.gl/f2rcO
>
> But we're in conflict because the colleague really argue about his
> "Hungarian Notation".
This simply adds far too much noise to code. If I need to know what type a
variable has, I'll look at its declaration, if any.
--
Cheers -- Tim
--- End Message ---
--- Begin Message ---
Hi.
I've got a piece of code that builds up a multi-meg test array for my
opensourced http://mediabeez.ws/products/htmlMicroscope var_dump()
improvement, and when I run it for longer than about 20 minutes, the
browser just calls it quits.. :( Firefox, and chrome.
I'd like to do this with a browser call, if all else fails I suppose I
can run the generation of the test array from the commandline, but I
prefer calling from the browser..
So, I'm doing ob_start(), then start the main loop which does echo
'.'; ob_flush(); flush();.
I've got my KeepAliveTime set to 25 seconds, as per
http://www.pctools.com/guides/registry/detail/891/
And I'm calling this from my browser to the domain name that points
back to the machine I run the browser on, latest wampserver on windows
7.
Calling via localhost doesn't work somehow.
Is there anything obvious I've missed?
--- End Message ---
--- Begin Message ---
On Mon, Jun 4, 2012 at 5:57 PM, rene7705 <[email protected]> wrote:
> Hi.
>
> I've got a piece of code that builds up a multi-meg test array for my
> opensourced http://mediabeez.ws/products/htmlMicroscope var_dump()
> improvement, and when I run it for longer than about 20 minutes, the
> browser just calls it quits.. :( Firefox, and chrome.
>
> I'd like to do this with a browser call, if all else fails I suppose I
> can run the generation of the test array from the commandline, but I
> prefer calling from the browser..
>
> So, I'm doing ob_start(), then start the main loop which does echo
> '.'; ob_flush(); flush();.
>
> I've got my KeepAliveTime set to 25 seconds, as per
> http://www.pctools.com/guides/registry/detail/891/
>
> And I'm calling this from my browser to the domain name that points
> back to the machine I run the browser on, latest wampserver on windows
> 7.
> Calling via localhost doesn't work somehow.
>
> Is there anything obvious I've missed?
>
Just to be sure, have you checked the Apache error logs for anything
obvious? (eg. out of memory?)
In case the browser closes the connection, you could use
ignore_user_abort [1] to be sure the script continues, though the
browser won't receive the result.
- Matijn
[1] www.php.net/manual/en/function.ignore-user-abort.php
--- End Message ---
--- Begin Message ---
Not sure if this is a bug or not...
I have run into an error when performing a conditional using iplong()
and the ~ bitwise operator
$ip = '0.0.0.0';
$mask = '24';
$end = (ip2long($ip) || (~ip2long($mask))) + 1;
PHP Fatal error: Unsupported operand types
I even tried to typecast the mask to (int)
--- End Message ---
--- Begin Message ---
On Mon, Jun 4, 2012 at 6:54 PM, jas <[email protected]> wrote:
> Not sure if this is a bug or not...
>
> I have run into an error when performing a conditional using iplong() and
> the ~ bitwise operator
>
> $ip = '0.0.0.0';
> $mask = '24';
>
> $end = (ip2long($ip) || (~ip2long($mask))) + 1;
>
> PHP Fatal error: Unsupported operand types
>
> I even tried to typecast the mask to (int)
>
The error is probably not where you suspect it to be. ip2long will
return false for ip2long($mask), because $mask is not a valid IP
address. The ~ operator is not supported for false.
- Matijn
--- End Message ---
--- Begin Message ---
On 06/04/2012 11:33 AM, Matijn Woudt wrote:
On Mon, Jun 4, 2012 at 6:54 PM, jas<[email protected]> wrote:
Not sure if this is a bug or not...
I have run into an error when performing a conditional using iplong() and
the ~ bitwise operator
$ip = '0.0.0.0';
$mask = '24';
$end = (ip2long($ip) || (~ip2long($mask))) + 1;
PHP Fatal error: Unsupported operand types
I even tried to typecast the mask to (int)
The error is probably not where you suspect it to be. ip2long will
return false for ip2long($mask), because $mask is not a valid IP
address. The ~ operator is not supported for false.
- Matijn
Strange... this works
$ip = '10.0.2.0';
$mask = '24';
Anything using 0.0.0.0 fails using the bitmask to calculate valid CIDR
ranges.
--- End Message ---
--- Begin Message ---
On Mon, Jun 4, 2012 at 8:38 PM, jas <[email protected]> wrote:
> On 06/04/2012 11:33 AM, Matijn Woudt wrote:
>>
>> On Mon, Jun 4, 2012 at 6:54 PM, jas<[email protected]> wrote:
>>>
>>> Not sure if this is a bug or not...
>>>
>>> I have run into an error when performing a conditional using iplong() and
>>> the ~ bitwise operator
>>>
>>> $ip = '0.0.0.0';
>>> $mask = '24';
>>>
>>> $end = (ip2long($ip) || (~ip2long($mask))) + 1;
>>>
>>> PHP Fatal error: Unsupported operand types
>>>
>>> I even tried to typecast the mask to (int)
>>>
>>
>> The error is probably not where you suspect it to be. ip2long will
>> return false for ip2long($mask), because $mask is not a valid IP
>> address. The ~ operator is not supported for false.
>>
>> - Matijn
>
>
> Strange... this works
>
> $ip = '10.0.2.0';
> $mask = '24';
>
> Anything using 0.0.0.0 fails using the bitmask to calculate valid CIDR
> ranges.
>
Yes, because with $ip being 0.0.0.0, the result of ip2long($ip) will
be zero. Zero evaluates to false when PHP is going to parse the ||
operator, and because of that, it continues to parse the rest.
When the result of ip2long($ip) is greater that zero, in case of some
other valid IP, it will evaluate to true and PHP will not even execute
the rest after the || because the result will be true anyway.
Did you mean to use a single | operator, as a bitwise OR?
- Matijn
--- End Message ---
--- Begin Message ---
Thank you guys for helping me clear things up.
-- Oliver
--- End Message ---
--- Begin Message ---
I'm working with a third-party PHP extension that makes a call to
zend_auto_global_disable_jit. However, in PHP5.4.5, there is no
zend_auto_global_disable_jit available, nor is it in its traditional
header. Commenting out all zend_auto_global_disable_jit calls causes
PHP to no longer recognize it as a valid extension, while leaving them
in attempts for an invalid method to be called.
The file in question is
https://github.com/mtorromeo/runkit/blob/master/runkit.c line 305. As
is relatively obvious, it's not part of a macro, and its removal
should not affect whether the library is a PHP extension or not -
perhaps it's based on PHP's static analysis? If it doesn't call the
function, it would access a global, possibly before the global has
been JIT initialized by the runtime. If this is the case, what is the
replacement function for PHP 5.4.5?
--
James Moore
--- End Message ---