473,809 Members | 2,763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 runNowUsingThis ParticularObjec tAndArray() 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 runNowUsingThis ParticularObjec tAndArray(&$act ionObject=false ,
&$getterObject= false) {
if (is_object($act ionObject) && is_object($gett erObject)) {
$countOfItemsTo LoopThrough = $selectObject->getCountOfRetu rn();
if (0 < $countOfItemsTo LoopThrough) {
$actionObject->beforeLoopStar ts();
for ($i=0; $i < $countOfItemsTo LoopThrough; $i++) {
$entry = $getterObject->getRowAsArrayW ithStringIndex( );
if ($i) $actionObject->betweenEachLoo p($i);
$actionObject->duringEachLoop ($entry, $i);
}
$actionObject->afterEachLoop( );
return $i;
}
} else {
if (is_object($act ionObject))
$this->resultsObjec t->addToErrorResu lts("In
runNowUsingThis ParticularObjec tAndArray(), in the class McLoop, we
expected the first parameter, actionObject, to be an object, but
instead we got this: $actionObject ");
if (is_object($get terObject))
$this->resultsObjec t->addToErrorResu lts("In
runNowUsingThis ParticularObjec tAndArray(), 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 2853
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
3372
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 or is it a benefit that C knows nearly nothing (what I can think about is that C is the largest common divisor defined on most available platforms)?
22
3089
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 so easy. Everything in the code either goes right to machine code, or links to a C library (often libc) or links to the kernel. Are there libc equivalents on non-unix OSes? -- Using M2, Opera's revolutionary e-mail client:...
13
1448
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 ; // note that m_Map is not changed, only read from }
0
1569
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 that it only installs the aspnet_client directory under a specified web site or even just the .net web sites on the server. I'm running several production IIS servers that have got a mix of .net and non-.net web sites on them and I don't want the...
16
1949
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 for licensing. Can they use PostgreSQL just like anyone else or do non-profits qualify as commercial use and need to consider other licensing? D. Stimits, stimits AT comcast DOT net ---------------------------(end of...
12
3158
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
5687
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 as designed or a bug ? Manuals say that the standby will inform the primary about the takeover but will not wait for acknowledgement, so the primary knows about whats going on. In my eyes primary should either switch to standby or shutdown...
3
2035
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 project and I get the same errors there: Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers.
2
3900
by: year1943 | last post by:
There was the same topic not so long ago, but as I see it stays w/o answer: http://groups.google.ru/group/comp.lang.c++/browse_thread/thread/9a05d7bba9394a60/fe109c899f916871?lnk=gst&q=locale+imbue&rnum=1&hl=ru#fe109c899f916871 As Bjarne Stroustrup said in his book, "in Stroustrup (retranslated from German) "Setting the global locale does not affect existing input/output streams. The streams continue to use those locales that were...
19
1746
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- exist*...but I'm beginning to get the sense that they actually interact -- or, perhaps more precisely, JavaScript acts upon CSS...but how, exactly??
0
10635
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10378
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7653
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3013
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.