php-general Digest 26 Jan 2013 16:24:44 -0000 Issue 8103

Topics (messages 320100 through 320105):

Late static binding behaves differently in PHP 5.3 and PHP 5.4
        320100 by: Keven
        320101 by: David Harkness
        320102 by: Keven

No error handling for - ldap_bind(): Unable to bind to server: Invalid 
credentials.
        320103 by: Sarno, Giuseppe

properly debugging php/httpd with gdb
        320104 by: Zippy Zeppoli

Strip emails from a document
        320105 by: Tedd Sperling

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Hello everybody,

I found a difference between late static binding in PHP 5.3 and PHP 5.4 and I 
cannot find any documentation to explain this difference.
Here is some code to show you this difference:

  class Foo
  {
    const MY_CONST = 'The Foo';
    static $my_var = self::MY_CONST;
  }

  class Bar extends Foo
  {
    const MY_CONST = 'The Bar';
    static $my_var = self::MY_CONST;
  }

  echo Bar::$my_var."\n";
  echo Foo::$my_var."\n";


In PHP 5.3 (tested on 5.3.2), the output is:

  The Bar
  The Foo

In PHP 5.4 (tested on 5.4.4 and 5.4.6), the output is:

  The Bar
  The Bar

It's confusing me, is this a bug or a feature?


Note all in both versions, the output is same if you call Foo before Bar:

  echo Foo::$my_var."\n";
  echo Bar::$my_var."\n";

Output in PHP 5.3 and PHP 5.4:

  The Foo
  The Bar

This is even more confusing for me since the result is not the same in PHP 5.4 
base on the statement you execute first...

Keven.

--- End Message ---
--- Begin Message ---
Hi Keven,

First, I don't see any late static binding being used here. LSB only
applies when you access a static member using the static keyword within a
class method. This code uses static properties but accesses them directly
without going through class methods. Here's an example of LSB:

    class Foo
    {
        static $my_var = 'The Foo';

        static function dump() {
            echo static::$my_var . "\n";    // Use Foo's or Bar's depending
on what appears before ::dump()
        }
    }

    class Bar extends Foo
    {
        static $my_var = 'The Bar';
    }

    Bar::dump();    // The Bar
    Foo::dump();    // The Foo

Here Foo::dump() uses LSB to pick the source of $my_var.

That being said, what you're seeing does look like a change (or bug) in how
PHP accesses constants. Given that it is order-dependent, my guess is that
5.4 introduced a bug that causes Bar to push its constant up into Foo. The
strange thing is that the constant is compiled into the class, and since
Bar extends Foo I would expect Foo to be compiled first regardless of the
order in which you access the static variable later.

David

--- End Message ---
--- Begin Message ---
Thank you for your response,

yes the name is not totally related to the message, but this behavior reminds 
me of LSB.
However, I found it while using Propel 1.6 on PHP 5.4 with nested_set behavior 
and I can tell now that Propel 1.6 + nested_set cannot work on PHP 5.4+ (I 
checked on PHP 5.5 and the behavior is the same as PHP 5.4).

I hope someone more competent than me will check this and be able to actually 
tag it as a bug or a feature.

Keven

--- End Message ---
--- Begin Message ---
Hello,
I am using php (5.4.11 windows) ldap extension and I am having problems when I 
bind to my LDAP server with wrong credentials.
The problem is that I get the warning: : ldap_bind(): Unable to bind to server: 
Invalid credentials no matter what I do.
I simply would like to handle the case and gracefully return false in my 
function (example below).
This problem is preventing me from post processing any PHP logic after bind.

I tried:

1-      error_reporting in php.ini (E_ALL & ~E_DEPRECATED & ~E_STRICT & 
~E_WARNING & ~E_USER_WARNING & ~E_RECOVERABLE_ERROR & ~E_ERROR   or even ~E_ALL)

2-      Diplay_errors is Off.

3-      Similar setting from code (ini_set etc.)

Can anybody please help ? I have seen many posts on internet but nothing been 
resolved.

Basic example:

$ds = ldap_connect($address);
if( !$ds ) return false;
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$bind = @ldap_bind($ds,$dn,$password);   --> warning.
if( !$bind )  return false;

Thanks,
Giuseppe.


This email and any files transmitted with it are confidential, proprietary
and intended solely for the individual or entity to whom they are addressed.
If you have received this email in error please delete it immediately.


--- End Message ---
--- Begin Message ---
Hello,
I've asked this question on the gdb as well as httpd mailing lists, so I am
turning to php community as a last resort. I am trying to debug my php apps
that core dump with gdb, but for some reason the core file is always
truncated (don't ask me about limits, they are properly set, been down that
road over and over).

So I'm wondering how others have done it successfully and have some
experience with it?

I'm familiar with xdebug, and use it frequently, but there's some things
that gdb can do that xdebug and debug code can't.

I am on linux, so unfortunately I cannot use dtrace with it (yet, I think
Oracle has or is creating a dtrace for linux, but it hasn't been fully
released yet).

Thanks for any insights.

--- End Message ---
--- Begin Message ---
Hi gang:

I thought I had a function to strip emails from a document, but I can't find it.

So, before I start writing a common script, do any of you have a simple script 
to do this?

Here's an example of the problem:

Before:

"Will Alex" <ale...@cit.msu.edu>;"Moita Zact" <za...@cit.msu.edu>;"Bob Arms" 
<ar...@cit.msu.edu>;"Meia Terms" <term...@cit.msu.edu>;

After:

ale...@cit.msu.edu
za...@cit.msu.edu
ar...@cit.msu.edu
term...@cit.msu.edu

Cheers,

tedd


_____________________
t...@sperling.com
http://sperling.com


--- End Message ---

Reply via email to