473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how does one get non-mandatory function parameters to pass by reference?

The following class method is being rejected by the PHP parser. If I
change the method paramaters and allow the objects to be passed as
copies, then the parser has no problem. Or, if I pass by reference but
set no default value, then the parser has no problems. I've resovled
this for now by taking out the "false" default values. But how shall I
handle those situations (there are many) where I wish to pass an
object by reference but I'm not sure I'll be passing one?

In short, how does one get non-mandatory function parameters to pass
by reference?
/**
* 12-28-03 - manipulator
*
* We want to go over a data set and commit a bunch of actions on the
data in that set. For instance, the class McShow uses
* a getterObject to get data from the datastore, which is then passed
into this method, and McShow also passes in an htmlObject
* as the action object, which takes the data given by the
getterObject and wraps in HTML and outputs it to the screen.
*
*
* @param - $actionObject - object - this is an object that has the 4
methods that are going to be called from within the loop. An
* example would be all the Html objects. The class McShow, for
instance, calls McLoop in its (McShow's) printToScreen() method,
* wherein it invokes runNowUsingThisParticularObjectAndArray() and
hands it an htmlObject as the first parameter.
*
* @param - $getterObject - object - this is going to be an object
that knows how to get data out of some data store, be it an array,
* the file system, or a database.
*
* 02-28-04 - PHP isn't letting me pass objects by reference and give
them a false default value
*
* public
* returns integer - number of times the loop iterated.
*/
function runNowUsingThisParticularObjectAndArray(&$actionOb ject=false,
&$getterObject=false) {
if (is_object($actionObject) && is_object($getterObject)) {
$countOfItemsToLoopThrough = $selectObject->getCountOfReturn();
if (0 < $countOfItemsToLoopThrough) {
$actionObject->beforeLoopStarts();
for ($i=0; $i < $countOfItemsToLoopThrough; $i++) {
$entry = $getterObject->getRowAsArrayWithStringIndex();
if ($i) $actionObject->betweenEachLoop($i);
$actionObject->duringEachLoop($entry, $i);
}
$actionObject->afterEachLoop();
return $i;
}
} else {
if (is_object($actionObject))
$this->resultsObject->addToErrorResults("In
runNowUsingThisParticularObjectAndArray(), in the class McLoop, we
expected the first parameter, actionObject, to be an object, but
instead we got this: $actionObject ");
if (is_object($getterObject))
$this->resultsObject->addToErrorResults("In
runNowUsingThisParticularObjectAndArray(), in the class McLoop, we
were expecting the second parameter to be an object for getting data
from a datastore, but instead we got this: $getterObject ");
}
}
}
Jul 17 '05 #1
1 2838
lawrence wrote:
In short, how does one get non-mandatory function parameters to pass
by reference?


You need Zend engine 2, available for PHP 5
http://www.php.net/zend-engine-2.php
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
by: Martin Marcher | last post by:
Hi, I've read several questions and often the answer was 'C knows nothing about .' So if C knows that little as some people say, what are the benefits, I mean do other languages know more...
22
by: Ryan M | last post by:
I've been programming for a while, but most of my experience is on unix. How do C compilers work on operating systems that weren't written in C? And that have no libc? Compiling C on unix seems...
13
by: Peteroid | last post by:
Why does reading a member of a std::map not considered const? For example: class My_Class { int Get_Map_Value( int index ) const // ** error ** not considered const!!! { return m_Map ; //...
0
by: richard.warner | last post by:
When you run 'aspnet_regiis -c', the aspnet_client directory is created under EVERY web site on the IIS server. It seems strange that there doesn't seem to be any way of running the command so...
16
by: D. Stimits | last post by:
A non-profit organization is interested in a new data application that would use a SQL storage system. I'm interested to know how non-profit companies that are not selling products are considered...
12
by: Vincent RICHOMME | last post by:
Hi, I am currently implementing some basic classes from .NET into modern C++. And I would like to know if someone would know a non mutable string class.
3
by: Joachim Klassen | last post by:
Hi all, if I accidentally use a TAKEOVER command with BY FORCE clause while primary and standby are in peer state I'll end up with two primary's (at least with FP10 and Windows). Is this works ...
3
by: Mark Leistner | last post by:
I am having problems getting a gridview to bind to custom objects under any non-full trust level. I created a test project to verify what I am seeing isn't a side effect of other code in my...
2
by: year1943 | last post by:
There was the same topic not so long ago, but as I see it stays w/o answer:...
19
by: Prisoner at War | last post by:
Okay, Folks, I guess my real burning concern all along is a "high-level" one: just how does JavaScript interact with CSS? Right now, my newbie self only knows JavaScript and CSS to *co-...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.