You can string functions together in PHP!

    Date: 11/11/10 (PHP Community)    Keywords: no keywords

    Does anybody know when that happened?

    I just stumbled across it out of sheer desperation when I was using DOMXPath to access the text value of several single nodes:

    $title = $xpath->query ('title', $ent)->item (0)->textContent;

    I'm absolutely certain that when I first started (4.0? 3.x?) this was illegal since you could not follow a function call with any operator on the return value. The parser simply did not allow it and so the above code could only be written:

    $nodelist = $xpath->query ('title', $ent);
    $node = $nodelist->item (0);
    $title = $node->textContent;

    Of course, they didn't have objects then but the same was true of arrays:
    $myFunction ()[0] was illegal, now it's not.

    Source: https://php.livejournal.com/680758.html

« Hmm... || Do x to items 1-7, then y... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home