SitePoint Sponsor

User Tag List

Page 1 of 4 1234 LastLast
Results 1 to 25 of 106

Hybrid View

  1. #1
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Word of warning for anyone about to use new versions of PHP

    I dunno if others have noticed with PHP 4.4.0 and 5.1.0b2, that they've disabled passing variables through temporaries to methods that have their data passed by reference...

    eg.

    <?php

    function a() { return array(); }
    function b(&$data) { /* ... */ }
    b(a());

    ?>

    ... ends up in ...
    Fatal error: Only variables can be passed by reference

    the result of a() is passed to b() in a temporary passed by reference. This behaviour has been disabled in new versions of PHP. It's just a word of warning to anyone as this does break a lot of existing code.

    This is all due to memory leaks caused by the reference counting in the Zend engine. What baffles e is why they can't just detect these variables and just make up some hidden anon variable name to deference into the current scope for temporaries.

  2. #2
    SitePoint Guru momos's Avatar
    Join Date
    Apr 2004
    Location
    Belgium
    Posts
    919
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the warning, I was about to instal 4.4. So I'd better wait a little longer...

  3. #3
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your example is wrong, it should have been:
    PHP Code:
    function &a() { return array(); }
    function 
    b(&$data) { /* ... */ }
    b(a()); 
    And it's a huge difference. Are you sure it doesn't work now ? (Im just too lazy to check it)

  4. #4
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bonefry
    Your example is wrong, it should have been:
    PHP Code:
    function &a() { return array(); }
    function 
    b(&$data) { /* ... */ }
    b(a()); 
    And it's a huge difference. Are you sure it doesn't work now ? (Im just too lazy to check it)
    Dead certain, well with PHP 5 at least. Hardly use PHP4 now tbh

    And no my example isn't wrong (It's just not efficient if you were looking at things from a C/C++ perspective). Admittedly, in most cases you would make a return by reference like you did, however if you wanted to return by value, it is perfectly legit., as a would return it's data by value, and it would copied into a temporary variable, which then gets passed by reference to b. In your case, everything is passed by reference, which is generally seen as more efficient if look things from a C perspective (the reality is that references don't really have any performance advantages in PHP unless you have really large memory blocks involved).

    Anyway, the fact of the matter is, whether you write it like I did or you did, it doesn't work. You need to deference anything that was going into a temporary varaible into a varaible now. It's a pain that many people will need to have to adjust to, and I think it's a silly move of Zend from this point of view. No other language imposes this retriction (I guess C++ & C are partly an exception as most C++ programmers will dereference variables into variables before passing into parameters in order to make code exception safe from memory leaks blah blah blah)

  5. #5
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MiiJaySung
    This is all due to memory leaks caused by the reference counting in the Zend engine. What baffles e is why they can't just detect these variables and just make up some hidden anon variable name to deference into the current scope for temporaries.
    Do you have a link for that?

    Douglas
    Hello World

  6. #6
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX
    Do you have a link for that?

    Douglas
    Not atm. I would say that what I've said though is pretty much right. I was having no end of trouble with PHP where it was leaking memory and segfaulting etc. I did a debug backtrace on PHP it's self via apachectl -X and --enable-debug in the ./configure, and traced it back to references loosing track of the reference count when the variable was used in a temporary context.

    See: http://bugs.php.net/bug.php?id=32963

    If you look at the source for PHP in the C code, you'll see that if you read between the lines. Because the PHP C code is pretty messy, it's hard to tell always what's going on (compare PHP's source to Ruby's C src, and Ruby's reads much cleaner)

    Anyway, I reported thi behavior in the bug report below ...

    http://bugs.php.net/bug.php?id=33643

    and thinking about it in retrospect, this change totally ties in with the mem leak stuff they published on the main PHP.NET site, and the problems I was having, so I'm 99% sure that what I am saying is right.

    Hopefully, the PHP team will change their documentation to reflect this. I'm so fed up with these sort of stupid engine level flaws/querks in PHP, that I'll be using Ruby for a lot of new things, so to some degree this doesn't affect too much I hope (any old PHP sites that need any fair amount of programming work done will gradually be migrated to RoR).

  7. #7
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the bugs link, will keep an eye on it. I guess this is one of the bugs/design flaws which stops you writing code like this:

    PHP Code:
    class Klass {
        function 
    talk() {
            echo 
    'Hello World!';
        }
    }

    (new 
    Klass)->talk(); 
    Re: a Ruby trick: if you have a block of ugly PHP code, comment it with a Ruby one-liner version. Takes up less space than an English description

    Douglas
    Hello World

  8. #8
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX
    Thanks for the bugs link, will keep an eye on it. I guess this is one of the bugs/design flaws which stops you writing code like this:

    PHP Code:
    class Klass {
        function 
    talk() {
            echo 
    'Hello World!';
        }
    }

    (new 
    Klass)->talk(); 
    Re: a Ruby trick: if you have a block of ugly PHP code, comment it with a Ruby one-liner version. Takes up less space than an English description

    Douglas
    LOL. Heh, that does assume that other coders are Ruby coders though I won't be using PHP for much longer. We have one very large project on PHP which needs regular updates, all the other PHP sites we have are only small and only get updeated on a monthly / yearly basis. We are in the process porting the big site to Rails as a learning curve to see how Ruby fairs for projects, (not to mention when you are learning a new system you need to be using it to really learn it). Also, on a side note, I'll be going to university in a few months anyway so I won't have as much involvement with existing PHP projects anyway.

  9. #9
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    compare PHP's source to Ruby's C src, and Ruby's reads much cleaner
    Was wondering when Ruby would be brought into this

    Re: a Ruby trick:
    PHP is not Ruby, and vice versa. If it's a bug, then too bad is my thought... Is it really detrimental to your development? Doubt it somehow, sure makes no difference to me though.

  10. #10
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston
    Was wondering when Ruby would be brought into this

    PHP is not Ruby, and vice versa. If it's a bug, then too bad is my thought... Is it really detrimental to your development? Doubt it somehow, sure makes no difference to me though.
    LOL. I don't know why people are anti Ruby. PHP isn't Ruby and can't do everything Ruby does, but Ruby does 99.99% of what PHP does, so it's fair enough to do something like Doug does. Anyway, there are a lot of people who seem to be anti Ruby, yet haven't used it for anything proper. You can't really against something unless you've had a fair degree of experience imo.

  11. #11
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MiiJaySung
    You can't really against something unless you've had a fair degree of experience imo.
    Surely you can? If the resistance is to the change in itself. Like, if you have invested years of experience into knowing php inside-out, and you don't feel like spending a lot of time getting under the skin of yet another language. (superior as it may be).

  12. #12
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MiiJaySung
    LOL. I don't know why people are anti Ruby. PHP isn't Ruby and can't do everything Ruby does, but Ruby does 99.99% of what PHP does, so it's fair enough to do something like Doug does. Anyway, there are a lot of people who seem to be anti Ruby, yet haven't used it for anything proper. You can't really against something unless you've had a fair degree of experience imo.
    People, it's all about the money. Java sells because it is enterprise-ready. PHP sells because it's good for fast development and most importantlly: outsourcing.

    Ruby does not sell (at least for a couple of years). When I first told by boss about Ruby he said "Ruby-what ?" and he is right. No proof that it's ready for the masses, no good documentation, no tools, no professional support, buggy and incomplete VM. Get over it.

    BTW: If you want to measure an industry, a better way of doing it, instead of googleing for pages containg "PHP" or "Ruby" go to any large jobs site like http://hotjobs.yahoo.com/ and search in there. Also it's also appropiate to search http://www.amazon.com for books on the subject and compare the number of titles. This should give you a better and healthier view of the whole picture.

    Since this is a PHP forum I thought a little Ruby bashing is appropiate. :P

  13. #13
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bonefry
    People, it's all about the money. Java sells because it is enterprise-ready. PHP sells because it's good for fast development and most importantlly: outsourcing.

    Ruby does not sell (at least for a couple of years). When I first told by boss about Ruby he said "Ruby-what ?" and he is right. No proof that it's ready for the masses, no good documentation, no tools, no professional support, buggy and incomplete VM. Get over it.

    BTW: If you want to measure an industry, a better way of doing it, instead of googleing for pages containg "PHP" or "Ruby" go to any large jobs site like http://hotjobs.yahoo.com/ and search in there. Also it's also appropiate to search http://www.amazon.com for books on the subject and compare the number of titles. This should give you a better and healthier view of the whole picture.

    Since this is a PHP forum I thought a little Ruby bashing is appropiate. :P

    Yes, it is partly down to money. For those who are motiviated by this, many are moving to .NET. MS have been very clever at trying to hit the middle of the road market here.

    As for your quote on Ruby. Well we still find that it's immature atm, and there are some issues that we are uncertain of, but the Ruby Community are making a big effort to make up good Documentation (their docs are pretty good imo), just look at the focus on tools like rdoc / rake. GEM's make it easy to deploy stuff like PEAR does, and while it lacks professional / commercial support, it does have a good *helpful* IRC community.

    As for Buggy incomplete VM? I totally disagree. It ain't half as flawed as PHP's.

    Anyway, that's enough Anti PHP blabber for a day. I'll leave it at that before I annoy anymore people :P

  14. #14
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MiiJaySung
    As for Buggy incomplete VM? I totally disagree. It ain't half as flawed as PHP's
    Yes, but the thing is PHP and Python/Java/.NET do not have the same target. Ruby on the other hand... not the same story. And last time I checked the Ruby VM didn't had support for threads. If this is the case, than that's not good, is it ?

    I like Ruby, but it still has a long way to go.

    BTW: I'm also sad to see the Zend homepage showing ads with "See why Oracle choose PHP" while PHP has serious issues that need to be fixed.

  15. #15
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why should really getting to learn another language be such a chore though?

  16. #16
    ********* Victim lastcraft's Avatar
    Join Date
    Apr 2003
    Location
    London
    Posts
    2,423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi.

    The PHP community is never going to advance if it keeps losing experienced developers at the top end. It used to be that PHPers would migrate away to Java, then it was Python and now it's Ruby. The developers are not just adding a new language, but switching away from PHP. All because of Zend's cavalier attitude to language level bugs.

    Perhaps the question is not "Is PHP enterprise ready?", but "Is Zend enterprise ready?".

    yours, Marcus
    Marcus Baker
    Testing: SimpleTest, Cgreen, Fakemail
    Other: Phemto dependency injector
    Books: PHP in Action, 97 things

  17. #17
    SitePoint Enthusiast
    Join Date
    Jan 2003
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lastcraft
    Perhaps the question is not "Is PHP enterprise ready?", but "Is Zend enterprise ready?".
    Ouch!!!

    Is that your own quote? Those are some pretty profound and hard-hitting words that probably have a lot of sober truth in them.

    I can see that quote being (mis)appropriated by the PHP FUD "community" - although, increasingly, it's looking a lot less FUDdy.

  18. #18
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lastcraft
    Hi.

    The PHP community is never going to advance if it keeps losing experienced developers at the top end. It used to be that PHPers would migrate away to Java, then it was Python and now it's Ruby. The developers are not just adding a new language, but switching away from PHP. All because of Zend's cavalier attitude to language level bugs.

    Perhaps the question is not "Is PHP enterprise ready?", but "Is Zend enterprise ready?".

    yours, Marcus
    * Nods in agreement *

    <rant>
    More and more half-decent coders (I would say experienced like you here, but I'm hardly what many would classify as expereinced) are moving away from PHP by the day. Like you said, the real reason for me is that Zend seem to have the wrong attitude. They seem to be following after Java. The one selling point for PHP was that PHP <> Java. Now that is going, people are moving on. At the same time, I also think there is a market incentive here. .NET has a lot more jobs and money seems to flow more freely in the capitalist environment that Microsoft have developed. At the same time, Python and Ruby seem to be developing appeal because of their simple nature. What sells Ruby to me is not just the cleanness of the language, and Rails, but it's small, simple and and very flexible (you can write shell scripts almost like you would would in BASH where as PHP shell scripts are littered in noise methods like shell / passthru, like wise Ruby has more mature GUI bindings that PHP GTK). The speed of development / elegantness of Ruby is a huge selling point for those who do find the time to look at Ruby. I think Ruby would gain a huge foothold if universities etc start using it in place of Java. This is something that is perfectly possible too.

    Zend's bad attitude to all of this just proves to existing PHP users that there is little reason for one to stay with PHP if they are prepared to make the jump. to somewhere with more of future. Backed by the fact that it will be a long time before PHP6 comes out is making it blindly obvious to those who can switch that "the grass is greener on the other side".

    The other thing that get me with Zend, is they seem to be pouring so many resources into marketing it's engine as Enterprise ready. To me this is just a classic case of running before you can walk. They need to adresss serious design flaws in the engine first, and their IDE is rough on the edges. They had a perfect chance to do this, when they developed PHP5. They've missed that chance, and as a result PHP5 seems to be following in the mistakes of PHP4 where serious language level changes seem to still be taking place throughout 5.1.x and 5.2.x
    </rant>

  19. #19
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MiiJaySung
    *Like you said, the real reason for me is that Zend seem to have the wrong attitude. They seem to be following after Java. The one selling point for PHP was that PHP <> Java. Now that is going, people are moving on. At the same time, I also think there is a market incentive here. .NET has a lot more jobs and money seems to flow more freely in the capitalist environment that Microsoft have developed. At the same time, Python and Ruby seem to be developing appeal because of their simple nature. What sells Ruby to me is not just the cleanness of the language, and Rails, but it's small, simple and and very flexible (you can write shell scripts almost like you would would in BASH where as PHP shell scripts are littered in noise methods like shell / passthru, like wise Ruby has more mature GUI bindings that PHP GTK).
    Wow, PHP is heavilly under attack. I can't believe it . However, I see some points that aren't true.

    1) PHP is far from being Java
    2) Java does not have the problem mentioned here and should not be mentioned
    3) The most wanted programmers are for Java and not .NET
    4) Python is around from 1991 and is far from new. It has allways developed appeal, and somehow it never succeded
    5) Ruby is just a toy (for at least 2 years to come)
    6) Perl is just plain ugly, and Perl 6 for now is just vaporware
    7) Who the fu*k builds desktop applications with Ruby or PHP-GTK ??? That's just . Python and Perl are far more well suited for such task.

  20. #20
    SitePoint Evangelist jplush76's Avatar
    Join Date
    Nov 2003
    Location
    Los Angeles, CA
    Posts
    460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Marcus,
    I agree with you and I attribute it to the immaturity of the OOP capabilities in PHP4 and lower. As you develop your skills and move to OOP concepts you realize php can only take you so far in your skillset building, however with PHP5 I think this will lessen the moving of PHP developers with the new OOP feature set.

    my 2 cents
    My-Bic - Easiest AJAX/PHP Framework Around
    Now Debug PHP scripts with Firebug!

  21. #21
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If Marcus' timeline is correct (I've not been around PHP long enough to know) then PHP5 is already two generations of leavers behind, as it seems to be heading towards Java-style OOP. There does seem to be support for that static style of OOP in the PHP community though, as you can see in the "Design an ApplicationController implementation together" thread:

    PHP Code:
    public function validate(DataObject $dataILogger $logger
    That seems to me like a step backwards, away from the dynamic nature of PHP. And I have to agree with Marcus' analysis, language level bugs worry me.

    Douglas
    Hello World

  22. #22
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Umm...

    I was only making a humourous effort in mentioning that I got the feeling that at some point Ruby would be mentioned, and my feeling was right on

    I think I agree with Marcus in that Zend at the moment is not actually helping the PHP community as well as it could being doing? They are pushing PHP to the larger corporatioins I suppose to some point, but maybe they're handling the feedback they get back, badly?

    They're certification program doesn't exactly put PHP in a good light either in my view. There is just something missing from it, and it doesn't do nothing for me

    As for PHP <> Python <> Ruby <> Java <> ..., you do need to use the language that is best suited to the task at hand. Ruby is relatively new to a lot of web developers, and sure doesn't get the online coverage that PHP and other languages do, at the moment.

    I've not used Ruby and have no intentions of doing so, as I feel PHP is capable enough but my interests lie elsewhere if I was to drop PHP in favour of something else...

  23. #23
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston
    As for PHP <> Python <> Ruby <> Java <> ..., you do need to use the language that is best suited to the task at hand. Ruby is relatively new to a lot of web developers, and sure doesn't get the online coverage that PHP and other languages do, at the moment.
    It is somewhat scary, googleing:

    PHP: 330,000,000
    Java: 147,000,000
    Python: 35,400,000
    Ruby: 14,300,000

    And that the top PHP pages are actually about PHP the language, unlike for Ruby!

    BTW, Google says that 1 PHP = 1 Philippine peso = 0.0177942 U.S. dollars.

    Douglas
    Hello World

  24. #24
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I am currently working with PHP4 but I would love to be able to use PHP5. The OOP support in PHP5 is just much better and more natural. Only my webserver ain't installed with PHP5, and the control panel doesn't seem to like PHP5 a lot. Oh well, maybe I should keep my fingers crossed that their will come a PHP5-based DirectAdmin version.

  25. #25
    SitePoint Enthusiast NotThatBright's Avatar
    Join Date
    Sep 2004
    Location
    @define(State_of_Chaos, 'NY');
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So PHP really is worth my 2 cents!!
    _______________________________________________________________
    Casino and Poker Blogs and Articles - Web Design and Programming Services


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •