ID: 21123 Comment by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Bogus Bug Type: Feature/Change Request Operating System: All PHP Version: 4.2.3 New Comment:
Oh and I'm surprised by the fact you appear to be a member of the PHP development group yet from a very valid request you take the opportunity to insult me. I've been developing PHP professionly since version 3.0.9. I think that's about 4 years now. I've found a lot of the 'staff' very friendly and helpful, Cardinal, Philip, even Rasmus at times. You however, chose to insult me rather than completely understand my request. Thanks, I'm glad I spent all that money on PHP shirts to help support the project. Previous Comments: ------------------------------------------------------------------------ [2002-12-20 18:04:11] [EMAIL PROTECTED] Apparently you aren't reading my entire comment. First off if you took the time to understand what depreciated means, Call Time Pass by Reference will be removed entirely from PHP. Meaning I can't turn it on in php.ini by setting allow_call_time_pass_reference. That option will no longer exist in future versions of PHP. Second, yes that is the way around it. And my point exactly. Removing Call Time Pass by Reference was intended to make PHP code a bit cleaner. Well instead of adding one character & to my function, I now have to create an entirely new function to add to my class. So wheres the benefit? No instead of consolidating it into one function I have to split it into two that do 99% the same thing due to the fact Call Time Pass by Reference was removed. I still don't see the reason for removing it at all. ------------------------------------------------------------------------ [2002-12-20 17:47:30] [EMAIL PROTECTED] 1) you can easily get around this with XForm::addByVal() / XForm::addByRef() 2) I wonder how you got around writing a "very large application" without ever looking in php.ini? ------------------------------------------------------------------------ [2002-12-20 17:27:33] [EMAIL PROTECTED] In my opinion I do not think depreciating and removing the Call Time Pass by Reference feature of PHP is a good idea. There are a number of valid reasons to use this feature, to which this feature is the only solution. While programming a very large web database application for my employer, I've found where this feature is extremely useful. Yet when I've upgraded to new versions of PHP I've come to find that it is depreciated. My example. In this application I've written a series of classes, I call them XElements. Each XElement is essentially a class that is dedicated to an XHTML 1.0 element. So for example, I have an XForm, XTable, XTd, XTr, etc. They all inherit the XElement class. The XElement class has a number of methods that are useful. The most important two are add() and draw(). The add() method takes one argument. This argument is then put into an array variable of the object, maintaining the order by call to add(). So each time I call add() it adds this argument to the end of the array. What are these arguments? They are the nested CDATA. Consider this: <form ...> <p> Name <input ... /> Password <input ... /> </p> </form> The way my code above would work is like this. $myForm =& new XForm(); $myP =& new XP(); $myForm->add(&$myP); $myP->add("Name"); $myInput1 =& new XInput(); $myP->add(&$myInput1); $myP->add("Password"); $myInput2 =& new XInput(); $myP->add(&$myInput2); $myForm->draw(); This is partially pseudo, since my real constructors have many arguments for attributes of the XHTML code, I've left them out of this example for clarity. Now with that in mind, onto draw(). The draw() method does one simple thing. It iterates through the array of CDATA, and writes it out either by 1) if it's a string, echo it, 2) if it's an object, assume its an XElement and call that XElement's draw(). You can see how it then works. draw() manages the closing tags, and knows which tags are allowed CDATA and which are not thus using /> instead of > as well. Now, with the above example we can see where Call Time Pass by Reference comes into play. If in the first part of my code, I did $myForm->add($myP); instead of $myForm->add(&$myP); that would create a copy of $myP and pass it to add(). Then any calls to $myP after that add() won't reflect the $myP stored in the CDATA Array. I could modify the declaration of add() so that it takes a reference for the argument, function add(&$arg) { ... }. However, then I go to do $myP->add("Name");, this would happen: Fatal error: Cannot pass parameter 1 by reference So what once would originally have only taken one function, would require two if Call Time Pass by Reference was removed. I'd have to create one function to add non-references, and one to add references. One could say I could have a function for adding string CDATA, and one for adding XElements, however there comes a time when I don't want to add a reference to a XElement, but rather have it store a copy. This may come into play if say I wanted to construct one XInput then change a field in the object and re-add it over and over, then I would omit the Call Time Pass by Reference. >From what I can gather, removing Call Time Pass by Reference was suppose to make it easier to read code, however if I have to add an additional function to manage non-references, I'm don't see the benefits anymore. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=21123&edit=1