Re: [PHP] Call-time pass-by-reference ??

2005-01-26 Thread Jason Wong
On Thursday 27 January 2005 14:47, Michael Gale wrote:

>  I am trying to start a small php ncurses app but the documenatation is
> not helping.

OK, I've never used the ncurse functions before, but cursory glance at the 
manual results in the following observations:

> What does the following mean:
>
> PHP Warning:  Call-time pass-by-reference has been deprecated - argument
> passed by value;  If you would like to pass it by reference, modify the
> declaration of ncurses_getmaxyx().  If you would like to enable
> call-time pass-by-reference, you can set allow_call_time_pass_reference
> to true in your INI file.  However, future versions may not support this
> any longer.  in /home/michael/gsmenu/gsmenu on line 10
>
>
> Here is my code:
>
> #!/usr/local/bin/php
> 
> $y=0;
> $x=0;
>
>
> $ncurses_session = ncurses_init();
> $main = ncurses_newwin(0,0,0,0);

OK, you've created a zero-sized window.

> ncurses_getmaxyx (&$main,$y,$x );

It is $y & $x that ought to be passed by reference, why are you using &$main? 
In any case as the above error message says you should be simply doing:

  ncurses_getmaxyx ($main, $y, $x);

> ncurses_border(1,1,1,1, 1,1,1,1);

You've specified not to draw any borders around your zero-sized window.

> ncurses_wrefresh($main);
> ncurses_end();
>
> ?>
>
> If I remove the "&" from main nothing happens at all,

So what did you expect to see?

> the php 
> documentation says that the variables should be passed from reference.

That bit of the documentation could be made clearer. It should probably say 
something along the lines of "... the variables *will* be passed by 
reference ...". I'm assuming that the function definition has defined $y & $x 
to be passed by reference.

> Any help would be appreciated.

I suggest you start by giving some dimensions to your window and possibly some 
borders as well.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Call-time pass-by-reference ??

2005-01-26 Thread Michael Gale
Hello,
	I am trying to start a small php ncurses app but the documenatation is 
not helping.

What does the following mean:
PHP Warning:  Call-time pass-by-reference has been deprecated - argument 
passed by value;  If you would like to pass it by reference, modify the 
declaration of ncurses_getmaxyx().  If you would like to enable 
call-time pass-by-reference, you can set allow_call_time_pass_reference 
to true in your INI file.  However, future versions may not support this 
any longer.  in /home/michael/gsmenu/gsmenu on line 10

Here is my code:
#!/usr/local/bin/php

$y=0;
$x=0;
$ncurses_session = ncurses_init();
$main = ncurses_newwin(0,0,0,0);
ncurses_getmaxyx (&$main,$y,$x );
ncurses_border(1,1,1,1, 1,1,1,1);
ncurses_wrefresh($main);
ncurses_end();
?>
If I remove the "&" from main nothing happens at all, the php 
documentation says that the variables should be passed from reference.

Any help would be appreciated.
Michael.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] call-time pass-by-reference feature really deprecated?

2003-06-19 Thread dorgon
Thanks for the explanation.
Yes, let us drop call-time pass-by-reference!! I'm with you. ;-)
/dorgon

Jason Wong wrote:
On Friday 20 June 2003 01:11, dorgon wrote:

Maybe, there's a setting for this in php.ini.
yes. there is:


Yes, I know there is ;-) The 'maybe' is maybe you have it set different on the 
two systems.


>>declaration of [runtime function name](). If you would like to enable
>>call-time pass-by-reference, you can set
>>allow_call_time_pass_reference to true in your INI file.
"pass-by-reference" has not been dropped, it is "Call-time
pass-by-reference" which is being deprecated.
so call-time pass-by-reference is giving parameters as reference to
functions, e.g.
function returnObjectToAccumulator(&$obj) {...}

If this feature is really dropped, how would you implement
ConnectionPools for DB-connections for instance, or any classes
managing a set of object and providing them by returning references?
many OOP design patterns (primarily adopted from java) would not be
possible anymore. I think this would be worth talking about.
Is there any plausible reason for that decision?


"Call-time pass-by-reference"
=
  function doo($i_may_or_may_not_be_a_reference) {
$i_may_or_may_not_be_a_reference++;
  }
  $i = 1;
  doo($i);
  echo $i; // 1
  doo(&$i);
  echo $i; // 2
// here doo() is not defined to have parameters passed by reference. The 
decision on whether to pass by reference is made at run-time, hence call-time  
pass-by-reference. It is this behaviour which is being deprecated.

So in the newer versions of PHP if call-time pass-by-reference is disabled and 
you wish to pass parameters by reference you'll have to define your functions 
accordingly:

  function doo(&$i_am_passed_by_reference) { ... }



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] call-time pass-by-reference feature really deprecated?

2003-06-19 Thread Jason Wong
On Friday 20 June 2003 01:11, dorgon wrote:
> > Maybe, there's a setting for this in php.ini.
>
> yes. there is:

Yes, I know there is ;-) The 'maybe' is maybe you have it set different on the 
two systems.

>  >>declaration of [runtime function name](). If you would like to enable
>  >>call-time pass-by-reference, you can set
>  >>allow_call_time_pass_reference to true in your INI file.
> >
> > "pass-by-reference" has not been dropped, it is "Call-time
> > pass-by-reference" which is being deprecated.
>
> so call-time pass-by-reference is giving parameters as reference to
> functions, e.g.
>
> function returnObjectToAccumulator(&$obj) {...}
>
> If this feature is really dropped, how would you implement
> ConnectionPools for DB-connections for instance, or any classes
> managing a set of object and providing them by returning references?
>
> many OOP design patterns (primarily adopted from java) would not be
> possible anymore. I think this would be worth talking about.
>
> Is there any plausible reason for that decision?

"Call-time pass-by-reference"
=
  function doo($i_may_or_may_not_be_a_reference) {
$i_may_or_may_not_be_a_reference++;
  }

  $i = 1;
  doo($i);
  echo $i; // 1
  doo(&$i);
  echo $i; // 2

// here doo() is not defined to have parameters passed by reference. The 
decision on whether to pass by reference is made at run-time, hence call-time  
pass-by-reference. It is this behaviour which is being deprecated.

So in the newer versions of PHP if call-time pass-by-reference is disabled and 
you wish to pass parameters by reference you'll have to define your functions 
accordingly:

  function doo(&$i_am_passed_by_reference) { ... }

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Federal grants are offered for... research into the recreation
potential of interplanetary space travel for the culturally disadvantaged.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] call-time pass-by-reference feature really deprecated?

2003-06-19 Thread dorgon
I think you are absolutely right.
thanx!
I'll fix it and see if the warning still remains.
/Dorgon
Bobby Patel wrote:
Isn't Call-time pass-by-reference the following

$variable = myFunction1(&$x); Where
myFunction1() is defined as function myFunction1($x)
Where as pass-be-reference is called as
$variable = myFunction2($x); Where is defined as function myFunction2
(&$Obj);
I think the latter is better anyways, because the caller shouldn't know the
internals of  the function, so you don't know if the function will copy the
argument and use that instead.
"Dorgon" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Maybe, there's a setting for this in php.ini.
yes. there is:
>>declaration of [runtime function name](). If you would like to enable
>>call-time pass-by-reference, you can set
>>allow_call_time_pass_reference to true in your INI file.

"pass-by-reference" has not been dropped, it is "Call-time

pass-by-reference"

which is being deprecated.
so call-time pass-by-reference is giving parameters as reference to
functions, e.g.
function returnObjectToAccumulator(&$obj) {...}

If this feature is really dropped, how would you implement
ConnectionPools for DB-connections for instance, or any classes
managing a set of object and providing them by returning references?
many OOP design patterns (primarily adopted from java) would not be
possible anymore. I think this would be worth talking about.
Is there any plausible reason for that decision?

/dorgon






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] call-time pass-by-reference feature really deprecated?

2003-06-19 Thread Bobby Patel
Isn't Call-time pass-by-reference the following

$variable = myFunction1(&$x); Where
myFunction1() is defined as function myFunction1($x)

Where as pass-be-reference is called as
$variable = myFunction2($x); Where is defined as function myFunction2
(&$Obj);

I think the latter is better anyways, because the caller shouldn't know the
internals of  the function, so you don't know if the function will copy the
argument and use that instead.

"Dorgon" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > Maybe, there's a setting for this in php.ini.
>
> yes. there is:
>  >>declaration of [runtime function name](). If you would like to enable
>  >>call-time pass-by-reference, you can set
>  >>allow_call_time_pass_reference to true in your INI file.
>
> > "pass-by-reference" has not been dropped, it is "Call-time
pass-by-reference"
> > which is being deprecated.
>
> so call-time pass-by-reference is giving parameters as reference to
> functions, e.g.
>
> function returnObjectToAccumulator(&$obj) {...}
>
> If this feature is really dropped, how would you implement
> ConnectionPools for DB-connections for instance, or any classes
> managing a set of object and providing them by returning references?
>
> many OOP design patterns (primarily adopted from java) would not be
> possible anymore. I think this would be worth talking about.
>
> Is there any plausible reason for that decision?
>
> /dorgon
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] call-time pass-by-reference feature really deprecated?

2003-06-19 Thread dorgon
Maybe, there's a setting for this in php.ini.
yes. there is:
>>declaration of [runtime function name](). If you would like to enable
>>call-time pass-by-reference, you can set
>>allow_call_time_pass_reference to true in your INI file.
"pass-by-reference" has not been dropped, it is "Call-time pass-by-reference" 
which is being deprecated.
so call-time pass-by-reference is giving parameters as reference to 
functions, e.g.

function returnObjectToAccumulator(&$obj) {...}

If this feature is really dropped, how would you implement 
ConnectionPools for DB-connections for instance, or any classes
managing a set of object and providing them by returning references?

many OOP design patterns (primarily adopted from java) would not be
possible anymore. I think this would be worth talking about.
Is there any plausible reason for that decision?

/dorgon

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] call-time pass-by-reference feature really deprecated?

2003-06-19 Thread Jason Wong
On Thursday 19 June 2003 23:53, dorgon wrote:

> I just got a warning message on a system using php version 4.3.1:
>
> 
> Warning: Call-time pass-by-reference has been deprecated - argument
> passed by value; If you would like to pass it by reference, modify the
> declaration of [runtime function name](). If you would like to enable
> call-time pass-by-reference, you can set allow_call_time_pass_reference
> to true in your INI file. However, future versions may not support this
> any longer.
> 
>
> This msg does not appear on my machine running php 4.3.2. Maybe it's
> because of the different configuration?

Maybe, there's a setting for this in php.ini.

> Will the pass-by-reference feature really be dropped?! Many software
> design patterns wouldn't be possible anymore! It's an essential feature.

"pass-by-reference" has not been dropped, it is "Call-time pass-by-reference" 
which is being deprecated.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
GIVE:   Support the helpless victims of computer error.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] call-time pass-by-reference feature really deprecated?

2003-06-19 Thread dorgon
Hi,

I just got a warning message on a system using php version 4.3.1:


Warning: Call-time pass-by-reference has been deprecated - argument 
passed by value; If you would like to pass it by reference, modify the 
declaration of [runtime function name](). If you would like to enable 
call-time pass-by-reference, you can set allow_call_time_pass_reference 
to true in your INI file. However, future versions may not support this 
any longer.


This msg does not appear on my machine running php 4.3.2. Maybe it's
because of the different configuration?
Will the pass-by-reference feature really be dropped?! Many software
design patterns wouldn't be possible anymore! It's an essential feature.
The config of the system throwing the warning is:

 './configure' '--with-mysql=/usr/local/mysql/' 
'--with-apache=../apache_1.3.27/' '--enable-track-vars' 
'--with-config-file-path=/etc/' '--with-imap=/usr/local/imap-2001a' 
'--with-gettext' '--with-exec-dir=/usr/local/typo3sh/bin' 
'--with-gd=/usr/local/typo3sh' '--with-jpeg-dir' '--with-png-dir' 
'--with-tiff-dir' '--with-ttf=/usr/local/typo3sh' '--with-zlib=yes' 
'--enable-gd-nativ-ttf' '--enable-ftp' '--with-xml'

/dorgon

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Call-time pass by reference has deprecated

2001-05-10 Thread Aaron Tuller

ummm, not to be insensitive but that error told you everything you 
want to know.

passing by reference at call time is putting an & in front of a 
variable.  if you want to make it work, either modify your script to 
not need call time pass by reference (you can change the function 
declaration to force a pass by reference) or you can simply (and I'm 
just cutting and pasting here from your message):

If you would like to enable call-time pass-by-reference, you can set 
allow_call_time_pass_reference to true in your INI file

by INI file it means the php.ini file.  you can find where this file 
is in phpinfo()

-aaron

At 2:04 AM +0100 5/11/01, Mr. Adam ALLEN. wrote:
>I have just recevied the following error, on version 4.0.3pl1. ( Linux
>sustain5.cobalt.com )
>
>I have not seen the error while running the same script on version 4.05
>(Win32), 4.0RC1, R.0PL1 or 3.0.14
>
>I'm not sure what the error is trying to tell me, or how to fix it (or make
>the error go away)
>
>Warning: Call-time pass-by-reference has been deprecated - argument passed
>by value; If you would like to pass it by reference, modify the declaration
>of [runtime function name](). If you would like to enable call-time
>pass-by-reference, you can set allow_call_time_pass_reference to true in
>your INI file. However, future versions may not support this any longer. in
>/home/sites/site91/web/globalc.lib on line 767
>
>I've enclosed a snip of the file and indicated line 767
>function
>getstats($server,$user,$password,$apop,$cntmessg,$from,$subject,$date)
>  {
>   $pop3_connection=new pop3_class;
>   $pop3_connection->hostname=$server;
>   if(($error=$pop3_connection->Open())=="")
>   {
>if(($error=$pop3_connection->Login($user,$password,$apop))=="")
>{
> this next line is 767
>  if(($error=$pop3_connection->Statistics(&$messages,&$size))=="")
>
>
>$cntmessg =$messages;
>for($i=1;$i<=$messages;$i++)
> {
>
>if(($error=$pop3_connection->RetrieveMessage($i,&$headers,&$body,-1))=="")
>  {
>for($line=0;$line{
> $line_data=strstr($headers[$line],":");
> $line_data=substr($line_data,1,strlen($line_data));
>
>$line_key=substr($headers[$line],0,(strlen($headers[$line])-strlen($line_dat
>a))-1);
> $line_key=trim(strtoupper($line_key));
> if($line_key=="FROM")
>  {
> $from[$i]=trim($line_data);
>  }
>
> if($line_key=="SUBJECT")
>  {
> $subject[$i]=trim($line_data);
>  }
> if($line_key=="DATE")
> {
>   $line_data=explode(",",$line_data);
> $tmp_data=explode(" ",trim($line_data[1]));
>   unset($tmp_data[count($tmp_data)-1]);
>   $date[$i]=implode("-",$tmp_data);
> }
> }
>   }
>  else
>  {
> return 0;
>  }
>}
>  }
>  else
>  {
>return 0;
>  }
>}
>else
>{
>  return 0;
>}
>  }
>  else
>   {
>return 0;
>   }
>
>  $pop3_connection->Close();
>  return 1;
>}
>
>
>Yours
>Mr. Adam ALLEN.
>[EMAIL PROTECTED]
>http://www.dynamicinteraction.co.uk
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Call-time pass by reference has deprecated

2001-05-10 Thread Mr. Adam ALLEN.

I have just recevied the following error, on version 4.0.3pl1. ( Linux
sustain5.cobalt.com )

I have not seen the error while running the same script on version 4.05
(Win32), 4.0RC1, R.0PL1 or 3.0.14

I'm not sure what the error is trying to tell me, or how to fix it (or make
the error go away)

Warning: Call-time pass-by-reference has been deprecated - argument passed
by value; If you would like to pass it by reference, modify the declaration
of [runtime function name](). If you would like to enable call-time
pass-by-reference, you can set allow_call_time_pass_reference to true in
your INI file. However, future versions may not support this any longer. in
/home/sites/site91/web/globalc.lib on line 767

I've enclosed a snip of the file and indicated line 767
function
getstats($server,$user,$password,$apop,$cntmessg,$from,$subject,$date)
 {
  $pop3_connection=new pop3_class;
  $pop3_connection->hostname=$server;
  if(($error=$pop3_connection->Open())=="")
  {
   if(($error=$pop3_connection->Login($user,$password,$apop))=="")
   {
 this next line is 767
 if(($error=$pop3_connection->Statistics(&$messages,&$size))=="")


   $cntmessg =$messages;
   for($i=1;$i<=$messages;$i++)
{

if(($error=$pop3_connection->RetrieveMessage($i,&$headers,&$body,-1))=="")
 {
   for($line=0;$lineClose();
 return 1;
}


Yours
Mr. Adam ALLEN.
[EMAIL PROTECTED]
http://www.dynamicinteraction.co.uk



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] call time pass by reference - help

2001-01-14 Thread php3

Addressed to: "Matt Friedman" <[EMAIL PROTECTED]>
  [EMAIL PROTECTED]

** Reply to note from "Matt Friedman" <[EMAIL PROTECTED]> Sun, 14 Jan 2001 
21:21:32 -0800
>
> There are a number of methods in the session class of phplib.
>
> With phplib and php4.0.4 I am seeing the following warnings: Warning:
> Call-time pass-by-reference has been deprecated - argument passed by
> value; If you would like to pass it by reference, modify the
> declaration of [runtime function name](). If you would like to enable
> call-time pass-by-reference, you can set
> allow_call_time_pass_reference to true in your INI file. However,
> future versions may not support this any longer. in
> /adm/vhosts/theparentreport.com/www/phplib/session.inc on line 273


In the existing code things are passed by reference where the calls are
made.  The places you see these warnings.  This style is going out of
style, in favor of one where you define passing by reference in the
function definition.

What to do:

Change the function calls from:


   function_whatever( &$var1, &$var2 );


to

   function_whatever( $var1, $var2 );


and change the finction definitions from:

   function function_whatever( $var1, $var2 ) {


to:

   function function_whatever( &$var1, &$var2 ) {


For now, since these are just warnings you could just turn down error
reporting, or enable allow_call_time_pass_reference as shown in the
warning, but you should seriously consider fixing the problem by
changing the code. Someday soon PHP will no longer allow the old syntax
at all.


For more information see:

   http://www.php.net/manual/en/html/language.references.html

and:

   http://www.php.net/manual/en/html/features.error-handling.html




Rick Widmer
Internet Marketing Specialists
http://www.developersdesk.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] call time pass by reference - help

2001-01-14 Thread Matt Friedman

There are a number of methods in the session class of phplib.

With phplib and php4.0.4 I am seeing the following warnings:
Warning: Call-time pass-by-reference has been deprecated - argument passed
by value; If you would like to pass it by reference, modify the declaration
of [runtime function name](). If you would like to enable call-time
pass-by-reference, you can set allow_call_time_pass_reference to true in
your INI file. However, future versions may not support this any longer. in
/adm/vhosts/theparentreport.com/www/phplib/session.inc on line 273

Warning: Call-time pass-by-reference has been deprecated - argument passed
by value; If you would like to pass it by reference, modify the declaration
of [runtime function name](). If you would like to enable call-time
pass-by-reference, you can set allow_call_time_pass_reference to true in
your INI file. However, future versions may not support this any longer. in
/adm/vhosts/theparentreport.com/www/phplib/session.inc on line 304

Warning: Call-time pass-by-reference has been deprecated - argument passed
by value; If you would like to pass it by reference, modify the declaration
of [runtime function name](). If you would like to enable call-time
pass-by-reference, you can set allow_call_time_pass_reference to true in
your INI file. However, future versions may not support this any longer. in
/adm/vhosts/theparentreport.com/www/phplib/session.inc on line 305

Warning: Call-time pass-by-reference has been deprecated - argument passed
by value; If you would like to pass it by reference, modify the declaration
of [runtime function name](). If you would like to enable call-time
pass-by-reference, you can set allow_call_time_pass_reference to true in
your INI file. However, future versions may not support this any longer. in
/adm/vhosts/theparentreport.com/www/phplib/session.inc on line 311

What should I do to fix this???


Matt Friedman


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]