[PHP] PHP Reference

2010-08-14 Thread Karl DeSaulniers

Hello all,
I was wondering, can you reference php in a url string like you can  
javascript.

EG:
javascript:someFunction()

Can you do something similar in php like

php:someFunction()

I am thinking that you can not do this, but was wondering if there  
was something like that.

Thanks,


Karl DeSaulniers
Design Drumm
http://designdrumm.com



Re: [PHP] PHP Reference

2010-08-14 Thread Peter Lind
On 14 August 2010 08:08, Karl DeSaulniers k...@designdrumm.com wrote:
 Hello all,
 I was wondering, can you reference php in a url string like you can
 javascript.
 EG:
 javascript:someFunction()

 Can you do something similar in php like

 php:someFunction()

 I am thinking that you can not do this, but was wondering if there was
 something like that.
 Thanks,

No, you can't.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype

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



Re: [PHP] PHP Reference

2010-08-14 Thread Karl DeSaulniers

That is what I thought.
Thank you for confirming.

Karl


On Aug 14, 2010, at 1:54 AM, Peter Lind wrote:

On 14 August 2010 08:08, Karl DeSaulniers k...@designdrumm.com  
wrote:

Hello all,
I was wondering, can you reference php in a url string like you can
javascript.
EG:
javascript:someFunction()

Can you do something similar in php like

php:someFunction()

I am thinking that you can not do this, but was wondering if there  
was

something like that.
Thanks,


No, you can't.

Regards
Peter

--
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype


Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Re: [PHP] PHP Reference

2010-08-14 Thread Andre Polykanine
Hello Karl,

If I understood you properly, try this:
?SomeFunction();?
-- 
With best regards from Ukraine,
Andre
Skype: Francophile
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion

- Original message -
From: Karl DeSaulniers k...@designdrumm.com
To: php-general php-general@lists.php.net
Date: Saturday, August 14, 2010, 9:08:20 AM
Subject: [PHP] PHP Reference

Hello all,
I was wondering, can you reference php in a url string like you can  
javascript.
EG:
javascript:someFunction()

Can you do something similar in php like

php:someFunction()

I am thinking that you can not do this, but was wondering if there  
was something like that.
Thanks,


Karl DeSaulniers
Design Drumm
http://designdrumm.com



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



Re: [PHP] PHP Reference

2010-08-14 Thread Karl DeSaulniers

Thank you Andre.
Yes, I had been doing it that way, but was just wondering if PHP had  
a reference like that of javascript with the colin : in it.


Best,

Karl


On Aug 14, 2010, at 3:50 AM, Andre Polykanine wrote:


Hello Karl,

If I understood you properly, try this:
?SomeFunction();?
--
With best regards from Ukraine,
Andre
Skype: Francophile
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion

- Original message -
From: Karl DeSaulniers k...@designdrumm.com
To: php-general php-general@lists.php.net
Date: Saturday, August 14, 2010, 9:08:20 AM
Subject: [PHP] PHP Reference

Hello all,
I was wondering, can you reference php in a url string like you can
javascript.
EG:
javascript:someFunction()

Can you do something similar in php like

php:someFunction()

I am thinking that you can not do this, but was wondering if there
was something like that.
Thanks,


Karl DeSaulniers
Design Drumm
http://designdrumm.com




Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Re: [PHP] PHP Reference

2010-08-14 Thread Ashley Sheridan
On Sat, 2010-08-14 at 01:57 -0500, Karl DeSaulniers wrote:

 That is what I thought.
 Thank you for confirming.
 
 Karl
 
 
 On Aug 14, 2010, at 1:54 AM, Peter Lind wrote:
 
  On 14 August 2010 08:08, Karl DeSaulniers k...@designdrumm.com  
  wrote:
  Hello all,
  I was wondering, can you reference php in a url string like you can
  javascript.
  EG:
  javascript:someFunction()
 
  Can you do something similar in php like
 
  php:someFunction()
 
  I am thinking that you can not do this, but was wondering if there  
  was
  something like that.
  Thanks,
 
  No, you can't.
 
  Regards
  Peter
 
  -- 
  hype
  WWW: http://plphp.dk / http://plind.dk
  LinkedIn: http://www.linkedin.com/in/plind
  BeWelcome/Couchsurfing: Fake51
  Twitter: http://twitter.com/kafe15
  /hype
 
 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com
 
 


The reason you can't is because PHP is on the server and Javascript is
local (e.g. the browser).

Even if the PHP code you're executing is through localhost, because PHP
needs the server to run, it has to be run on the server, and exposing
functions directly like this would expose all sorts of security issues
(imagine calling up a getUserDetails() on a website you're not logged
into for example, which would mean every function of a system would need
some sort of user auth check and would slow the whole thing to a crawl)

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] PHP Reference

2010-08-14 Thread Karl DeSaulniers


On Aug 14, 2010, at 5:19 AM, Ashley Sheridan wrote:


On Sat, 2010-08-14 at 01:57 -0500, Karl DeSaulniers wrote:


That is what I thought.
Thank you for confirming.

Karl


On Aug 14, 2010, at 1:54 AM, Peter Lind wrote:

 On 14 August 2010 08:08, Karl DeSaulniers k...@designdrumm.com
 wrote:
 Hello all,
 I was wondering, can you reference php in a url string like you  
can

 javascript.
 EG:
 javascript:someFunction()

 Can you do something similar in php like

 php:someFunction()

 I am thinking that you can not do this, but was wondering if there
 was
 something like that.
 Thanks,

 No, you can't.

 Regards
 Peter

 --
 hype
 WWW: http://plphp.dk / http://plind.dk
 LinkedIn: http://www.linkedin.com/in/plind
 BeWelcome/Couchsurfing: Fake51
 Twitter: http://twitter.com/kafe15
 /hype

Karl DeSaulniers
Design Drumm
http://designdrumm.com




The reason you can't is because PHP is on the server and Javascript  
is local (e.g. the browser).


Even if the PHP code you're executing is through localhost, because  
PHP needs the server to run, it has to be run on the server, and  
exposing functions directly like this would expose all sorts of  
security issues (imagine calling up a getUserDetails() on a website  
you're not logged into for example, which would mean every function  
of a system would need some sort of user auth check and would slow  
the whole thing to a crawl)


Thanks,
Ash
http://www.ashleysheridan.co.uk





I see. Very good point. Thanks Ash.
I figured it was because of the whole pre-processing part of PHP.
Thanks for the explination.
Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com



Re: [PHP] PHP Reference

2010-08-14 Thread tedd

At 1:08 AM -0500 8/14/10, Karl DeSaulniers wrote:

Hello all,
I was wondering, can you reference php in a url string like you can 
javascript.

EG:
javascript:someFunction()

Can you do something similar in php like

php:someFunction()

I am thinking that you can not do this, but was wondering if there 
was something like that.

Thanks,


Karl:

As others have answered, no php doesn't work that way.

However, you can still send/receive strings through a url via a 
$_GET) and direct the actions of a receiving php script and you can 
do the same thing via a $_POST.


As such, a php:someFunction() could be a:

url?php=someFunction

Where the receiving script takes the command and runs someFunction().

However, I would shorten it a bit and say

url?php=18

Where php would be the command to run a function and 18 would be the 
function you want to run.


So, while you can't use the same syntax as javascript, you can get 
the same performance.


Cheers,

tedd


--
---
http://sperling.com/

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



Re: [PHP] PHP Reference

2010-08-14 Thread Karl DeSaulniers

Thanks tedd.


On Aug 14, 2010, at 7:45 AM, tedd wrote:


At 1:08 AM -0500 8/14/10, Karl DeSaulniers wrote:

Hello all,
I was wondering, can you reference php in a url string like you  
can javascript.

EG:
javascript:someFunction()

Can you do something similar in php like

php:someFunction()

I am thinking that you can not do this, but was wondering if there  
was something like that.

Thanks,


Karl:

As others have answered, no php doesn't work that way.

However, you can still send/receive strings through a url via a  
$_GET) and direct the actions of a receiving php script and you can  
do the same thing via a $_POST.


As such, a php:someFunction() could be a:

url?php=someFunction

Where the receiving script takes the command and runs someFunction().

However, I would shorten it a bit and say

url?php=18

Where php would be the command to run a function and 18 would be  
the function you want to run.


So, while you can't use the same syntax as javascript, you can get  
the same performance.


Cheers,

tedd


--
---
http://sperling.com/


Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



[PHP] Re: reference variables

2009-05-22 Thread Shawn McKenzie
kranthi wrote:
 i have this script
 
 ?php
 $x = 1;
 $y = 2;
 $a1 = array($x, $y);
 $a2 = array($x, $y);
 $a2[0] = 3;
 print_r($a1);
 print_r($a2);
 ?
 
 i am expecting
 
 Array
 (
 [0] = 3
 [1] = 2
 )
 Array
 (
 [0] = 3
 [1] = 2
 )
 
 
 while i m getting
 
 Array
 (
 [0] = 1
 [1] = 2
 )
 Array
 (
 [0] = 3
 [1] = 2
 )
 
 
 any ideas why this is happening?? or am i missing something..?
 the same is the case when i replace
 $a2[0] = 3; with
 $a1[0] = 3;
 $x = 3;
 
 Kranthi.
 

$a2[0] was assigned the value of $x or 1, so when you change $a2[0],
that's all that changes.  You have changed the value 1 to 3. $a1[0] is a
reference to $x, so if you change $a1[0] it will change $x, but not
$a2[0] because it is not a reference to $x.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Re: reference variables

2009-05-22 Thread kranthi
thank you for the reply.

i had a small misunderstanding regarding variable reference...now its clear

but..

the output of

?php
$x = 1;
$a1 = array($x);
var_dump($a1);
?

is
array(1) {
  [0]= int(1)
}

while for

?php
$x = 1;
$a1 = array($x);
var_dump($a1[0]);
?

it is

int(1)

can u tell me what  signifies here??


Re: [PHP] Re: reference variables

2009-05-22 Thread Ashley Sheridan
On Fri, 2009-05-22 at 07:44 -0500, Shawn McKenzie wrote:
 kranthi wrote:
  i have this script
  
  ?php
  $x = 1;
  $y = 2;
  $a1 = array($x, $y);
  $a2 = array($x, $y);
  $a2[0] = 3;
  print_r($a1);
  print_r($a2);
  ?
  
  i am expecting
  
  Array
  (
  [0] = 3
  [1] = 2
  )
  Array
  (
  [0] = 3
  [1] = 2
  )
  
  
  while i m getting
  
  Array
  (
  [0] = 1
  [1] = 2
  )
  Array
  (
  [0] = 3
  [1] = 2
  )
  
  
  any ideas why this is happening?? or am i missing something..?
  the same is the case when i replace
  $a2[0] = 3; with
  $a1[0] = 3;
  $x = 3;
  
  Kranthi.
  
 
 $a2[0] was assigned the value of $x or 1, so when you change $a2[0],
 that's all that changes.  You have changed the value 1 to 3. $a1[0] is a
 reference to $x, so if you change $a1[0] it will change $x, but not
 $a2[0] because it is not a reference to $x.
 
 -- 
 Thanks!
 -Shawn
 http://www.spidean.com
 
To get the results you expect, you should remove the  from the
assignment, as this is assigning by reference, rather than by value like
Shawn said, or use an  for $a2 as well.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Re: reference variables

2009-05-22 Thread Shawn McKenzie
kranthi wrote:
 thank you for the reply.
 
 i had a small misunderstanding regarding variable reference...now its clear
 
 but..
 
 the output of
 
 ?php
 $x = 1;
 $a1 = array($x);
 var_dump($a1);
 ?
 
 is
 array(1) {
   [0]= int(1)
 }
 
 while for
 
 ?php
 $x = 1;
 $a1 = array($x);
 var_dump($a1[0]);
 ?
 
 it is
 
 int(1)
 
 can u tell me what  signifies here??
 

In the first instance you are var_dumping the entire array so it shows
the structure/values of the array elements thus showing a reference to a
var that is int(1).  In the second instance you are var_dumping a
specific var so you get the value of the var int(1).  I'm not sure if
there is a reason that it doesn't show that it is a reference, but the
same is true here:

$x = 1;
$y = $x;

var_dump($y);

int(1)

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] PHP-reference

2008-05-16 Thread Daniel Kressler

Hi!

I want to know, if it's allowed to write an own online reference for PHP, 
with own examples and so on?


I'm looking forward to hearing from you.


Greetings from Germany

Daniel 



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



Re: [PHP] PHP-reference

2008-05-16 Thread Daniel Brown
On Fri, May 16, 2008 at 5:24 PM, Daniel Kressler [EMAIL PROTECTED] wrote:
 Hi!

 I want to know, if it's allowed to write an own online reference for PHP,
 with own examples and so on?

Hello, fellow Daniel.  ;-P

Absolutely!  In fact, you're encouraged to write references and
examples for PHP, and to share your knowledge with the community.  Let
us know how it comes along for you, and be sure to send the URL.

 Greetings from Germany

Greetings from Olyphant, Pennsylvania, USA.  Have a great weekend!

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] PHP-reference

2008-05-16 Thread Daniel Kressler


Daniel Brown [EMAIL PROTECTED] wrote:
On Fri, May 16, 2008 at 5:24 PM, Daniel Kressler [EMAIL PROTECTED] 
wrote:

Hi!

I want to know, if it's allowed to write an own online reference for PHP,
with own examples and so on?


   Hello, fellow Daniel.  ;-P

   Absolutely!  In fact, you're encouraged to write references and
examples for PHP, and to share your knowledge with the community.  Let
us know how it comes along for you, and be sure to send the URL.


Greetings from Germany


   Greetings from Olyphant, Pennsylvania, USA.  Have a great weekend!


Hello Daniel ;-),

Thank you for your reply!
This is not a problem, if the results are presentable, I will not hesitate 
to communicate.


Many greetings and also a nice weekend!

Daniel 



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



[PHP] ZVAL reference counter code execution

2007-11-21 Thread Bill Rausch

Hi all,

Do I have to worry about the ZVAL overflow vulnerability if I don't 
use unserialize() in my code? Or is it used behind the scenes whether 
I call it directly or not?


I have a web server running PHP 4.4.4 with only one custom 
application running on it. The server is dedicated to this one 
application.


Thanks,

Bill

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



[PHP] strange reference behavior

2007-09-01 Thread Robert Enyedi

Hi,

I've been studying the PHP reference mechanism (with PHP 5.2.1) and I'm 
unsure if the following behavior is normal.


This code works as expected:

$a = 2;
$b = $a;
//$c = $a;
$c = $b;
$a = 1;

echo $c.\n; // Prints 2 as expected

but this one does not:

$a = 2;
$b = $a;
$c = $a;
$c = $b; // Should overwrite the previous assignment, so $c
 // should get a copy of $b (and NOT a reference)
$a = 1;

echo $c.\n; // I would expect 2, but prints 1

Could anyone please clarify why this happens?

Regards,
Robert

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



Re: [PHP] strange reference behavior

2007-09-01 Thread Martin Ellingham

Robert Enyedi wrote:

Hi,

I've been studying the PHP reference mechanism (with PHP 5.2.1) and 
I'm unsure if the following behavior is normal.


This code works as expected:

$a = 2;
$b = $a;
//$c = $a;
$c = $b;
$a = 1;

echo $c.\n; // Prints 2 as expected

but this one does not:

$a = 2;
$b = $a;
$c = $a;
$c = $b; // Should overwrite the previous assignment, so $c
 // should get a copy of $b (and NOT a reference)
$a = 1;

echo $c.\n; // I would expect 2, but prints 1


Could anyone please clarify why this happens?

Regards,
Robert

This is because PHP5 has changed the default behaviour and $a = $b is 
now call by reference as standard.


That's my understanding of it.

Martin

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



Re: [PHP] strange reference behavior

2007-09-01 Thread Robert Cummings
On Sat, 2007-09-01 at 13:06 +0300, Robert Enyedi wrote:
 Hi,
 
 I've been studying the PHP reference mechanism (with PHP 5.2.1) and I'm 
 unsure if the following behavior is normal.
 
 This code works as expected:
 
   $a = 2;
   $b = $a;
   //$c = $a;
   $c = $b;
   $a = 1;
 
   echo $c.\n; // Prints 2 as expected
 
 but this one does not:
 
   $a = 2;
   $b = $a;
   $c = $a;
   $c = $b; // Should overwrite the previous assignment, so $c
// should get a copy of $b (and NOT a reference)
   $a = 1;
   
   echo $c.\n; // I would expect 2, but prints 1
 
 Could anyone please clarify why this happens?

Sure...


1: $a = 2;
2: $b = $a;
3: $c = $a;
4: $c = $b;   // Should overwrite the previous assignment, so $c
5:// should get a copy of $b (and NOT a reference)
6: $a = 1;
7:
8: echo $c.\n; // I would expect 2, but prints 1

By line number...

1: Assign 2 to a variable called $a
2: Assign to $b a reference to $a
3: Assign to $c a reference to $a
4: Assign the value of $b to $c
   (this does NOT break $c's reference to $a)
6: Assign the value 1 to $a
   ($a is currently referenced by $b and $c)
8: Echo $c which should be 1. You will get the same result
   in PHP4

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] strange reference behavior

2007-09-01 Thread Robert Cummings
On Sat, 2007-09-01 at 11:39 +0100, Martin Ellingham wrote:
 Robert Enyedi wrote:
  Hi,
 
  I've been studying the PHP reference mechanism (with PHP 5.2.1) and 
  I'm unsure if the following behavior is normal.
 
  This code works as expected:
 
  $a = 2;
  $b = $a;
  //$c = $a;
  $c = $b;
  $a = 1;
 
  echo $c.\n; // Prints 2 as expected
 
  but this one does not:
 
  $a = 2;
  $b = $a;
  $c = $a;
  $c = $b; // Should overwrite the previous assignment, so $c
   // should get a copy of $b (and NOT a reference)
  $a = 1;
  
  echo $c.\n; // I would expect 2, but prints 1
 
  Could anyone please clarify why this happens?
 
  Regards,
  Robert
 
 This is because PHP5 has changed the default behaviour and $a = $b is 
 now call by reference as standard.

In the above example no objects have been used. As such, nothing has
changed in the above semantics that do not exist in PHP4.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] strange reference behavior

2007-09-01 Thread Robert Enyedi

Thanks for the clarifications.

Regards,
Robert

Robert Cummings wrote:

On Sat, 2007-09-01 at 11:39 +0100, Martin Ellingham wrote:

Robert Enyedi wrote:

Hi,

I've been studying the PHP reference mechanism (with PHP 5.2.1) and 
I'm unsure if the following behavior is normal.


This code works as expected:

$a = 2;
$b = $a;
//$c = $a;
$c = $b;
$a = 1;

echo $c.\n; // Prints 2 as expected

but this one does not:

$a = 2;
$b = $a;
$c = $a;
$c = $b; // Should overwrite the previous assignment, so $c
 // should get a copy of $b (and NOT a reference)
$a = 1;

echo $c.\n; // I would expect 2, but prints 1


Could anyone please clarify why this happens?

Regards,
Robert

This is because PHP5 has changed the default behaviour and $a = $b is 
now call by reference as standard.


In the above example no objects have been used. As such, nothing has
changed in the above semantics that do not exist in PHP4.

Cheers,
Rob.


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



[PHP] Object reference into variable?

2007-08-07 Thread GMail

Hello,

I have a question (what a surprise :-) )

I browsed the archives, but didn't find what I'm looking for.
I have an object instance stored in some variable (like $myobject). I want 
to save this instance into another variable (like $tempobject). I thought, 
this will be the way:

 $myobject = new MyObject();
 $tempobject = $myobject;
(or I tried this too:
 $tempobject = $myobject)

None of them worked, like I cannot access methods in the object:
 $tempobject-Foo()
gives me an error: calling to method on a non-object variable.

How can I tell PHP that $tempobject is a class instance of MyObject, and 
that I can use it's methods?


Thanks,
SanTa

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



RE: [PHP] gloabl reference behavior question?

2005-07-21 Thread Ford, Mike
On 20 July 2005 23:40, Surendra Singhi wrote:

 Hello,
 
 (1)
 When I try this code:
 ?php
 
 $var_global = stuff;
 function f1() {
   global $var_global;

This is equivalent to creating a $var_global which is local to the function,
and making it be a reference to the global $var_global -- effectively:

$var_global = $GLOBALS['var_global'];


   $var_local = array(1,2);
   $var_global = $var_local;

But this assigns a new reference to $var_local to the (local) $var_global,
thus breaking the reference to the (global) $var_global -- so the (global)
$var_global isn't changed by this assignment.

 }

Thus, when the function returns, the (local) $var_global disappears, and the
(global) $var_global comes back into scope with its value unchanged.

 f1();
 print_r($var_global);
  
 I get the output:
 
 stuff
 
 where as I was expecting junk value or null.
 
 
 My question is that, because the array is created locally and we
 pass it by reference (without copying) so on the exit of
 function, its value
 is lost, but how does the global variable gets back its old value?

See description above.

 Is it something which is not defined by the PHP language
 reference and is
 implementation specific?

No this is described in the manual at
http://php.net/global#language.variables.scope.references

To do what you're trying to do, you should make use of the $GLOBALS
superglobal:

$GLOBALS['var_global'] = $var_local;

But that seems very dodgy -- and, since $var_local disappears when the
function returns anyway, why not just:

$GLOBALS['var_global'] = array(1,2);

Overall, I'd be somewhat suspicious about what your function is trying to
do, as the whole approach seems rather convoluted to me.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] gloabl reference behavior question?

2005-07-21 Thread Richard Lynch
On Wed, July 20, 2005 3:39 pm, Surendra Singhi said:
 Hello,

 (1)
 When I try this code:
 ?php

 $var_global = stuff;
 function f1() {
   global $var_global;
   $var_local = array(1,2);
   $var_global = $var_local;
 }
 f1();
 print_r($var_global);
 ?
 I get the output:

 stuff

 where as I was expecting junk value or null.


 My question is that, because the array is created locally and we
 pass it by reference (without copying) so on the exit of function, its
 value
 is lost, but how does the global variable gets back its old value?

 Is it something which is not defined by the PHP language reference and is
 implementation specific? And in this case instead of giving the global
 variable some junk value or null value, the implementation decides to
 store
 the old values?

PHP is not C.

The  operator is not, as far as I know, defined for an array assignment
operation.

True, you can use  in the parameter list in some versions to keep PHP
from copying the whole array.  But that does not legitimatize what you are
doing, I don't think.

I could be 100% wrong. I've never even *TRIED* to use a reference to an
array because I simply don't want to write code that confusing in the
first place.

That's why I use PHP to build web pages instead of C.

YMMV

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] gloabl reference behavior question?

2005-07-20 Thread Surendra Singhi
Hello,

(1)
When I try this code:
?php

$var_global = stuff;
function f1() {
  global $var_global;
  $var_local = array(1,2);
  $var_global = $var_local;
}
f1();
print_r($var_global);
?
I get the output:

stuff

where as I was expecting junk value or null.


My question is that, because the array is created locally and we
pass it by reference (without copying) so on the exit of function, its value
is lost, but how does the global variable gets back its old value?

Is it something which is not defined by the PHP language reference and is
implementation specific? And in this case instead of giving the global
variable some junk value or null value, the implementation decides to store
the old values?

Thanks.
-- 
Surendra Singhi

http://www.spikesource.com

http://www.public.asu.edu/~sksinghi/

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



[PHP] Returning reference problem

2005-01-29 Thread Jon
Starting over since my last thread had too little effort put in it.  I
have this script that should create a multi-demensional array that would
resemble a directory structure.  The problem is that after adding one
element to a folder it appears to be creating a new object instead of
adding another item to the current object.  So there can only be one
file or folder in the parent folder with the exception of the top
level. My entire script is below.

Thanks, Jon

? 
class dir {

  var $name; 
  var $subdirs; 
  var $files; 
  var $num; 
  var $prio;

  function dir($name,$num,$prio) { 
$this-name = $name; 
$this-num = $num; 
$this-prio = $prio; 
$this-files = array(); 
$this-subdirs = array(); 
  }

  function addFile($file) { 
$this-files[] = $file; 
return $file; 
  }

  function addDir($dir) { 
$this-subdirs[] = $dir; 
return $dir; 
  }

  function findDir($name) { 
  foreach($this-subdirs as $v){ 
if($v-name == $name) 
  return $v; 
  } 
  return false; 
  }

  function draw($parent) {


echo('d.add('.$this-num.','.$parent.','.$this-name.\,.$this-prio.);\n);

  foreach($this-subdirs as $v) { 
  $v-draw($this-num); 
  }

  foreach($this-files as $v) 
  if(is_object($v)) { 
echo(d.add(.$v-num.,.$this-num.,
\.$v-name.\,.$v-prio.);\n); 
  } 
  } 
}


class file {

  var $name; 
  var $prio; 
  var $size; 
  var $num;

  function file($name,$num,$size,$prio) { 
$this-name = $name; 
$this-num = $num; 
$this-size = $size; 
$this-prio = $prio;

  }

} 
$arFiles = array 
  ( 
  0 = array 
( 
'path' = array 
  ( 
  0 = 'folder1', 
  1 = 'subfolder1', 
  2 = 'file1.ext' 
  ), 
'length' = 5464, 
'size' = 8765 
), 
  1 = array 
( 
'path' = array 
  ( 
  0 = 'folder1', 
  1 = 'subfolder1', 
  2 = 'file2.ext' 
  ), 
'length' = 5464, 
'size' = 8765 
), 
  2 = array 
( 
'path' = array 
  ( 
  0 = 'folder1', 
  1 = 'subfolder2', 
  2 = 'file1.ext' 
  ), 
'length' = 5464, 
'size' = 8765 
), 
  3 = array 
( 
'path' = array 
  ( 
  0 = 'folder2', 
  1 = 'subfolder1', 
  2 = 'file1.ext' 
  ), 
'length' = 5464, 
'size' = 8765 
) 
  ); 
$prio = array(); 
  for($i=0;$icount($arFiles);$i++) 
 $prio[$i] = -1;

 $dirnum = count($arFiles); 
 $tree = new dir(/,$dirnum,isset($prio[$dirnum])?$prio[$dirnum]:-1);

 foreach( $arFiles as $filenum = $file) { 
  $depth = count($file['path']); 
  $branch = $tree; 
  for($i=0; $i  $depth; $i++){ 
if ($i != $depth-1){ 
  $d = $branch-findDir($file['path'][$i]); 
echo BRBTree after find dir:/B; 
print_r($tree); 
  if($d) 
$branch = $d; 
  else{ 
$dirnum++; 
$d = $branch-addDir(new dir($file['path'][$i], $dirnum,
(isset($prio[$dirnum])?$prio[$dirnum]:-1))); 
echo BRBTree after add dir:/B; 
print_r($tree); 
$branch = $d; 
  } 
}else{ 
  $branch-addFile(new
file($file['path'][$i]. (.$file['length'].),$filenum,$file['size'],
$prio[$filenum]));

echo BRBTree after add file:/B; 
print_r($tree);} 
  } 
} 
$tree-draw(-1); 
?

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



Re: [PHP] Returning reference problem

2005-01-29 Thread Jochem Maas
Jon wrote:
Starting over since my last thread had too little effort put in it.  I
have this script that should create a multi-demensional array that would
resemble a directory structure.  The problem is that after adding one
element to a folder it appears to be creating a new object instead of
adding another item to the current object.  So there can only be one
file or folder in the parent folder with the exception of the top
level. My entire script is below.
Thanks, Jon
? 
class dir {

  var $name; 
  var $subdirs; 
  var $files; 
  var $num; 
  var $prio;

  function dir($name,$num,$prio) { 
$this-name = $name; 
$this-num = $num; 
$this-prio = $prio; 
$this-files = array(); 
$this-subdirs = array(); 
  }

  function addFile($file) { 
$this-files[] = $file; 
return $file; 
  }
a missing ampersand above might being causing you problems...
function addFile($file) {
 ^---
  function addDir($dir) { 
$this-subdirs[] = $dir; 
return $dir; 
  }

  function findDir($name) { 
  foreach($this-subdirs as $v){ 
if($v-name == $name) 
  return $v; 
  } 
  return false; 
  }

  function draw($parent) {
echo('d.add('.$this-num.','.$parent.','.$this-name.\,.$this-prio.);\n);
  foreach($this-subdirs as $v) { 
  $v-draw($this-num); 
  }

  foreach($this-files as $v) 
  if(is_object($v)) { 
echo(d.add(.$v-num.,.$this-num.,
\.$v-name.\,.$v-prio.);\n); 
  } 
  } 
}

class file {
  var $name; 
  var $prio; 
  var $size; 
  var $num;

  function file($name,$num,$size,$prio) { 
$this-name = $name; 
$this-num = $num; 
$this-size = $size; 
$this-prio = $prio;

  }
} 
$arFiles = array 
  ( 
  0 = array 
( 
'path' = array 
  ( 
  0 = 'folder1', 
  1 = 'subfolder1', 
  2 = 'file1.ext' 
  ), 
'length' = 5464, 
'size' = 8765 
), 
  1 = array 
( 
'path' = array 
  ( 
  0 = 'folder1', 
  1 = 'subfolder1', 
  2 = 'file2.ext' 
  ), 
'length' = 5464, 
'size' = 8765 
), 
  2 = array 
( 
'path' = array 
  ( 
  0 = 'folder1', 
  1 = 'subfolder2', 
  2 = 'file1.ext' 
  ), 
'length' = 5464, 
'size' = 8765 
), 
  3 = array 
( 
'path' = array 
  ( 
  0 = 'folder2', 
  1 = 'subfolder1', 
  2 = 'file1.ext' 
  ), 
'length' = 5464, 
'size' = 8765 
) 
  ); 
$prio = array(); 
  for($i=0;$icount($arFiles);$i++) 
 $prio[$i] = -1;

 $dirnum = count($arFiles); 
 $tree = new dir(/,$dirnum,isset($prio[$dirnum])?$prio[$dirnum]:-1);

 foreach( $arFiles as $filenum = $file) { 
  $depth = count($file['path']); 
  $branch = $tree; 
  for($i=0; $i  $depth; $i++){ 
if ($i != $depth-1){ 
  $d = $branch-findDir($file['path'][$i]); 
echo BRBTree after find dir:/B; 
print_r($tree); 
  if($d) 
$branch = $d; 
  else{ 
$dirnum++; 
$d = $branch-addDir(new dir($file['path'][$i], $dirnum,
(isset($prio[$dirnum])?$prio[$dirnum]:-1))); 
echo BRBTree after add dir:/B; 
print_r($tree); 
$branch = $d; 
  } 
}else{ 
  $branch-addFile(new
file($file['path'][$i]. (.$file['length'].),$filenum,$file['size'],
$prio[$filenum]));

echo BRBTree after add file:/B; 
print_r($tree);} 
  } 
} 
$tree-draw(-1); 
?

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


Re: [PHP] Get reference count on a variable.

2004-08-21 Thread Hannes Magnusson
On Sat, 21 Aug 2004 04:10:53 +
[EMAIL PROTECTED] (Curt Zirzow) wrote:

 * Thus wrote Robert Cummings:
  Hi All,
  
  I think I'm looking for something that doesn't exist, but just in
  case thought I'd check the list. Does anyone know if a PHP function
  exists to get the number of references on a given variable's data? I was
  hoping to create a way for a factory to automatically recycle resources
  without the need for the developer to call some kind of free() method.
  If I could get the internal reference count then I'd be able to
  determine if it is free by virtue of only 1 reference (the factory).
  This is for PHP4 btw, the solution is trivial in PHP5 using destructors.
 
 unfortantly there isn't a method to determain this.
 
 Be careful with PHP5, i'm not sure if its applicable in your
 situation, but there does seem to be rumor that php5 objects are
 assigned by reference, which isn't true:
http://zend.com/expert_qa/qas.php?id=41single=1
please read :)

 - Hannes

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



Re: [PHP] Get reference count on a variable.

2004-08-21 Thread Curt Zirzow
* Thus wrote Robert Cummings:
 On Sat, 2004-08-21 at 00:10, Curt Zirzow wrote:
  * Thus wrote Robert Cummings:
   Hi All,
   
   I think I'm looking for something that doesn't exist, but just in
   case thought I'd check the list. Does anyone know if a PHP function
   exists to get the number of references on a given variable's data? I was
   hoping to create a way for a factory to automatically recycle resources
   without the need for the developer to call some kind of free() method.
   If I could get the internal reference count then I'd be able to
   determine if it is free by virtue of only 1 reference (the factory).
   This is for PHP4 btw, the solution is trivial in PHP5 using destructors.
  
  unfortantly there isn't a method to determain this.
  
  Be careful with PHP5, i'm not sure if its applicable in your
  situation, but there does seem to be rumor that php5 objects are
  assigned by reference, which isn't true:
  
  $o1 = new object();
  $o2 = $o1;
  unset($o2);
  
  the Object still exists, and the destructor isn't called.
  
  vs.
  
  $o3 = new object();
  $o4 = $o3;
  unset($o3);

Sorry, those unset's should be:

$o2 = null;
and
$o3 = null;


It's was to demonstrate that = and = are *not* the same thing as
one would believe since the term 'assigned by reference' is used.



Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

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



Re: [PHP] Get reference count on a variable.

2004-08-21 Thread Robert Cummings
On Sat, 2004-08-21 at 10:24, Curt Zirzow wrote:
 * Thus wrote Robert Cummings:
  On Sat, 2004-08-21 at 00:10, Curt Zirzow wrote:
   * Thus wrote Robert Cummings:
Hi All,

I think I'm looking for something that doesn't exist, but just in
case thought I'd check the list. Does anyone know if a PHP function
exists to get the number of references on a given variable's data? I was
hoping to create a way for a factory to automatically recycle resources
without the need for the developer to call some kind of free() method.
If I could get the internal reference count then I'd be able to
determine if it is free by virtue of only 1 reference (the factory).
This is for PHP4 btw, the solution is trivial in PHP5 using destructors.
   
   unfortantly there isn't a method to determain this.
   
   Be careful with PHP5, i'm not sure if its applicable in your
   situation, but there does seem to be rumor that php5 objects are
   assigned by reference, which isn't true:
   
   $o1 = new object();
   $o2 = $o1;
   unset($o2);
   
   the Object still exists, and the destructor isn't called.
   
   vs.
   
   $o3 = new object();
   $o4 = $o3;
   unset($o3);
 
 Sorry, those unset's should be:
 
 $o2 = null;
 and
 $o3 = null;
 
 It's was to demonstrate that = and = are *not* the same thing as
 one would believe since the term 'assigned by reference' is used.

As exemplified in the sample script I sent in my last response and by
the link sent by Hannes Magnusson, in PHP5 the following have identical
behaviour:

$o1 = new Foo();
$o2 = $o1;

// Is same as...

$o1 = new Foo();
$o2 = $o1;

This was not true in PHP4 which is what a developer from PHP4 coming to
PHP5 needs to be aware of when using objects.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Get reference count on a variable.

2004-08-21 Thread Curt Zirzow
* Thus wrote Robert Cummings:
 
 As exemplified in the sample script I sent in my last response and by
 the link sent by Hannes Magnusson, in PHP5 the following have identical
 behaviour:
 
 $o1 = new Foo();
 $o2 = $o1;
 
 // Is same as...
 
 $o1 = new Foo();
 $o2 = $o1;

But = and = are not identical:

?php
class foo { };

$a = new foo();
$b = $a;

var_dump($b); /* object #1 */
$a = null;
var_dump($b); /* object #1 */

$c = new foo();
$d = $c;

var_dump($d); /* object #2 */
$c = null;
var_dump($d); /* NULL */

?


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

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



Re: [PHP] Get reference count on a variable.

2004-08-21 Thread Robert Cummings
On Sat, 2004-08-21 at 11:21, Curt Zirzow wrote:
 * Thus wrote Robert Cummings:
  
  As exemplified in the sample script I sent in my last response and by
  the link sent by Hannes Magnusson, in PHP5 the following have identical
  behaviour:
  
  $o1 = new Foo();
  $o2 = $o1;
  
  // Is same as...
  
  $o1 = new Foo();
  $o2 = $o1;
 
 But = and = are not identical:
 
 ?php
 class foo { };
 
 $a = new foo();
 $b = $a;
 
 var_dump($b); /* object #1 */
 $a = null;
 var_dump($b); /* object #1 */
 
 $c = new foo();
 $d = $c;
 
 var_dump($d); /* object #2 */
 $c = null;
 var_dump($d); /* NULL */

Hmmm this is a different situation than you first presented. Here you
are modifying the variable and not unsetting it. Unsetting it does the
expected symbolic unlinking. However it seems (probably for
compatibility reasons) that PHP will not overwrite an object which was
symbolically linked without a reference. Now I can see what to watch out
for and indeed this isn't obvious :) To illustrate the confusion I've
modified your example to show that indeed we have a reference when
modifying the object (but as said re-assignment as special behaviour):

?php

class foo { var $member = 1; };

$a = new foo();
$b = $a;

$a-member = 10;
var_dump($b); /* object #1 */
$a = null;
var_dump($b); /* object #1 */

$c = new foo();
$d = $c;

$c-member = 20;
var_dump($d); /* object #2 */
$c = null;
var_dump($d); /* NULL */

We know that $b is a reference to $a because when we modified the member
var using $a-member then $b's member was also changed -- thus $b is the
same object as $a.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Get reference count on a variable.

2004-08-21 Thread Daniel Schierbeck
Robert Cummings wrote:
In PHP5 to get a copy of, versus a reference to, an object the developer
must call the __clone() method for the target object:
$obj = new Foo();
$copyNotReference = $obj-__clone();
The correct syntax for that is:
$obj = new Foo;
$copyNotReference = clone $obj;
Cheers, Daniel
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Get reference count on a variable.

2004-08-21 Thread Robert Cummings
On Sat, 2004-08-21 at 14:38, Daniel Schierbeck wrote:
 Robert Cummings wrote:
  In PHP5 to get a copy of, versus a reference to, an object the developer
  must call the __clone() method for the target object:
  
  $obj = new Foo();
  $copyNotReference = $obj-__clone();
 
 The correct syntax for that is:
 
   $obj = new Foo;
   $copyNotReference = clone $obj;

Ahh cool. I guess I was reading an old document. Perhaps from before a
keyword was added for better code clarity :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Get reference count on a variable.

2004-08-21 Thread Daniel Schierbeck
Robert Cummings wrote:
On Sat, 2004-08-21 at 14:38, Daniel Schierbeck wrote:
Robert Cummings wrote:
In PHP5 to get a copy of, versus a reference to, an object the developer
must call the __clone() method for the target object:
   $obj = new Foo();
   $copyNotReference = $obj-__clone();
The correct syntax for that is:
$obj = new Foo;
$copyNotReference = clone $obj;

Ahh cool. I guess I was reading an old document. Perhaps from before a
keyword was added for better code clarity :)
Cheers,
Rob.
Hehe, no problem mate. By the way, does anyone know what happened to the 
delete keyword? I saw it in a Zend article before the final release of 
PHP 5, but i can't find it anywhere.

Ooops, off-topic, soory ;)
Best regards,
Daniel
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Get reference count on a variable.

2004-08-20 Thread Robert Cummings
Hi All,

I think I'm looking for something that doesn't exist, but just in
case thought I'd check the list. Does anyone know if a PHP function
exists to get the number of references on a given variable's data? I was
hoping to create a way for a factory to automatically recycle resources
without the need for the developer to call some kind of free() method.
If I could get the internal reference count then I'd be able to
determine if it is free by virtue of only 1 reference (the factory).
This is for PHP4 btw, the solution is trivial in PHP5 using destructors.

Thanks in advance.
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Get reference count on a variable.

2004-08-20 Thread Curt Zirzow
* Thus wrote Robert Cummings:
 Hi All,
 
 I think I'm looking for something that doesn't exist, but just in
 case thought I'd check the list. Does anyone know if a PHP function
 exists to get the number of references on a given variable's data? I was
 hoping to create a way for a factory to automatically recycle resources
 without the need for the developer to call some kind of free() method.
 If I could get the internal reference count then I'd be able to
 determine if it is free by virtue of only 1 reference (the factory).
 This is for PHP4 btw, the solution is trivial in PHP5 using destructors.

unfortantly there isn't a method to determain this.

Be careful with PHP5, i'm not sure if its applicable in your
situation, but there does seem to be rumor that php5 objects are
assigned by reference, which isn't true:

$o1 = new object();
$o2 = $o1;
unset($o2);

the Object still exists, and the destructor isn't called.

vs.

$o3 = new object();
$o4 = $o3;
unset($o3);

The object will no longer exist, destructor is called.


To elaborate a bit more on this... objects in php5 add a new
layer to variable existance. 

When an object is created it creates itself into its own memory
space and a new variable ($o1) is allocated to point to that
objects memory space. 

When the variable ($o1) is assigned to another variable ($o2), a
memory is allocated to point to the object as well. So now
two allocated variables are pointing to the same object. When one
of the variables is destroyed, since another variable still points
to the object, the object will continue to exist. Until all
variables pointing to that object no longer exits.

In unix filesystem terms, a variable of an object is very much like
how a hard link is treated.  The allocated filename (variable in
php's case), points to the allocated data (object). When no other
filename points to the same data, the data is released from usage.

In the later example (using =),  the new variable created ($o4),
points to ($o3).  So, as the manual explains, the new variable
($o4) is a symoblic link to the original variable ($o3).


I hope that wasn't too much info :)


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

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



Re: [PHP] Get reference count on a variable.

2004-08-20 Thread Robert Cummings
On Sat, 2004-08-21 at 00:10, Curt Zirzow wrote:
 * Thus wrote Robert Cummings:
  Hi All,
  
  I think I'm looking for something that doesn't exist, but just in
  case thought I'd check the list. Does anyone know if a PHP function
  exists to get the number of references on a given variable's data? I was
  hoping to create a way for a factory to automatically recycle resources
  without the need for the developer to call some kind of free() method.
  If I could get the internal reference count then I'd be able to
  determine if it is free by virtue of only 1 reference (the factory).
  This is for PHP4 btw, the solution is trivial in PHP5 using destructors.
 
 unfortantly there isn't a method to determain this.
 
 Be careful with PHP5, i'm not sure if its applicable in your
 situation, but there does seem to be rumor that php5 objects are
 assigned by reference, which isn't true:
 
 $o1 = new object();
 $o2 = $o1;
 unset($o2);
 
 the Object still exists, and the destructor isn't called.
 
 vs.
 
 $o3 = new object();
 $o4 = $o3;
 unset($o3);
 
 The object will no longer exist, destructor is called.
 
 
 To elaborate a bit more on this... objects in php5 add a new
 layer to variable existance. 
 
 When an object is created it creates itself into its own memory
 space and a new variable ($o1) is allocated to point to that
 objects memory space. 
 
 When the variable ($o1) is assigned to another variable ($o2), a
 memory is allocated to point to the object as well. So now
 two allocated variables are pointing to the same object. When one
 of the variables is destroyed, since another variable still points
 to the object, the object will continue to exist. Until all
 variables pointing to that object no longer exits.
 
 In unix filesystem terms, a variable of an object is very much like
 how a hard link is treated.  The allocated filename (variable in
 php's case), points to the allocated data (object). When no other
 filename points to the same data, the data is released from usage.
 
 In the later example (using =),  the new variable created ($o4),
 points to ($o3).  So, as the manual explains, the new variable
 ($o4) is a symoblic link to the original variable ($o3).

Hmmm, I think you got some wires crossed :) Your two examples are
identical in functionality; except that your assertion that the object
no longer exists in example 2 is incorrect. In PHP5 object assignment
results in a reference assignment instead of a copy as in PHP4. Try
running the following sample script:

?
class Foo
{
var $foo = 0;

function __destruct()
{
echo 'Destruction: '.$this-foo.\n;
}
}

$o1 = new Foo();
$o2 = $o1;

$o1-foo = 1;

echo Checkpoint 1\n;
unset( $o1 );
echo Checkpoint 2\n;
unset( $o2 );
echo Checkpoint 3\n;

$o3 = new Foo();
$o4 = $o3;

$o3-foo = 2;

echo Checkpoint A\n;
unset( $o3 );
echo Checkpoint B\n;
unset( $o4 );
echo Checkpoint C\n;

So to take your example of symbolic links. When a new object is created
the memory is allocated and a symbolic link is created to that memory.
Then when you assign the object to another variable then another
symbolic link is created. So in your examples the mere assignment of the
newly created object:

$o1 = new object();

creates a symbolic link. Thus when the __destruct() method is
automatically called I can be certain that no symbolic links exist. So
for my factory example the __destruct() method could inform the factory
that the the resource consumed by the object being destroyed is now
re-usable.

In PHP5 to get a copy of, versus a reference to, an object the developer
must call the __clone() method for the target object:

$obj = new Foo();
$copyNotReference = $obj-__clone();

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



[PHP] Re: Reference Scripts: Imaging Database, Recursion, Age Validation, Reg Ex

2004-07-02 Thread Torsten Roehr
Jason Paschal [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Some things crop up while coding that I do not often use, so that I tend
to
 forget the proper way to handle them and end up researching it and going
 through the same inoperable code again and again until I end up with
 something that works.

 Finally decided to host the code on my site and thought someone else might
 benefit from it.

 Storing Images in MySQL and Displaying them with PHP:
 http://www.dailymedication.com/modules.php?name=Forumsfile=viewtopict=15

 Recursion (Word Permutations/Jumble):
 http://www.dailymedication.com/modules.php?name=Forumsfile=viewtopict=11

 Age Validation (Determine Age from Birthdate):
 http://www.dailymedication.com/modules.php?name=Forumsfile=viewtopict=14

 Regular Expressions (Finding links in Web Code/ Gallery Image Ripper):
 http://www.dailymedication.com/modules.php?name=Forumsfile=viewtopict=13

 They all have working demos except for the Imaging Database stuff.  Hope
 these can help somebody.  Plan to be adding more soon.


Thanks Jason for sharing your code with us. Greatly appreciated!

Torsten Roehr

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



[PHP] Symbol reference problem with pspell in PHP5 compile

2004-03-18 Thread electroteque
Hi there, i have tried the phpinstall list with no luck i continually get
this error on solaris for some strange reason, i had to install 2 totally
seperate libiconv's so one could sit in /usr/local as php kept trying to
look there, now i keep getting this error

Undefined   first referenced
 symbol in file
aspell_speller_store_replacementext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
aspell_speller_add_to_session   ext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
delete_aspell_speller   ext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
new_aspell_config   ext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
aspell_speller_error_number ext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
aspell_string_enumeration_next  ext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
delete_aspell_string_enumerationext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
aspell_word_list_elements   ext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
to_aspell_speller   ext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
aspell_error_messageext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
aspell_speller_save_all_word_lists  ext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
aspell_error_number ext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
aspell_speller_clear_sessionext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
delete_aspell_configext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
new_aspell_speller  ext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
aspell_speller_checkext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
aspell_speller_error_messageext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
aspell_speller_add_to_personal  ext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
aspell_speller_suggest  ext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
aspell_config_replace   ext/pspell/pspell.lo  (symbol belongs to
imp
licit dependency /opt/csw/lib/libaspell.so.15)
ld: fatal: Symbol referencing errors. No output written to sapi/cli/php
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1


any ideas ?

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



[PHP] Empty Reference to an Object

2004-01-13 Thread Sebastian Ossio
Hi,

I´m trying to give an empty reference as a parameter, in a function. Or 
rather make a parameter that is a reference optional.

I have a function that should react differently if it is given an object 
or not. It works, but it gives me a warning that the second argument is 
not being given obviously.

Sadly I cannot make the parameter optional in the function definition 
because mine has to be a reference. One can´t do such a thing as

function( $parameter1,  objectparameter = NULL)

this results into a parsing error.

I cannot believe that there is no way of making an object parameter 
optional.

So tell me please what I´m missing.

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


[PHP] Empty reference parameter

2004-01-13 Thread Sebastian Ossio
Hi,

I´m trying to give an empty reference as a parameter of a function. Or 
rather, make a parameter that is a reference optional.

I have a function that should react differently if it is given an object 
or not. It works, but it gives me a warning that the second argument is 
not being given obviously.

Sadly I cannot make the parameter optional in the function definition 
because mine has to be a reference. One can´t do such a thing as

function( $parameter1,  objectparameter = NULL)

this results into a parsing error.

I cannot believe that there is no way of making an object parameter 
optional.

So tell me please what I´m missing.

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


Re: [PHP] Empty Reference to an Object

2004-01-13 Thread Richard Davey
Hello Sebastian,

Tuesday, January 13, 2004, 3:09:39 PM, you wrote:

SO I cannot believe that there is no way of making an object parameter
SO optional.

function ($parameter1, $parameter2 = NULL)
{
 // etc
}

If passed to your function, $parameter2 will be your object (or
string or whatever you wanted), if not passed in it'll be null.

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



Re: [PHP] Empty Reference to an Object

2004-01-13 Thread Jimmy Lantz
At 16:14 2004-01-13, you wrote:
Hello Sebastian,

Tuesday, January 13, 2004, 3:09:39 PM, you wrote:

SO I cannot believe that there is no way of making an object parameter
SO optional.
function ($parameter1, $parameter2 = NULL)
{
 // etc
}
If passed to your function, $parameter2 will be your object (or
string or whatever you wanted), if not passed in it'll be null.
this might work this is an ugly solution from the top of my head, not tested:
?php
$myObject = (ifYour object exists)? $yourObject : new stdClass;
foo(blaha,$myObject);
function foo($para1,$param2){
if(get_class($param2) =='stdClass') $param2 = NULL; // get_class 
might return stdclass not sure
}
?
/ Jimmy
--
Best regards,
 Richardmailto:[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Empty reference parameter

2004-01-13 Thread Tom Rogers
Hi,

Wednesday, January 14, 2004, 1:10:53 AM, you wrote:
SO Hi,

SO I´m trying to give an empty reference as a parameter of a function. Or
SO rather, make a parameter that is a reference optional.

SO I have a function that should react differently if it is given an object
SO or not. It works, but it gives me a warning that the second argument is
SO not being given obviously.

SO Sadly I cannot make the parameter optional in the function definition
SO because mine has to be a reference. One can´t do such a thing as

SO function( $parameter1,  objectparameter = NULL)

SO this results into a parsing error.

SO I cannot believe that there is no way of making an object parameter
SO optional.

SO So tell me please what I´m missing.


Try doing it in 2 steps

$ref = false;
function test($var)
  if(is_object($var)){
echo object passed;
  }
}

test($ref);

$ref = new object;

test($ref);


-- 
regards,
Tom

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



RE: [PHP] Empty Reference to an Object

2004-01-13 Thread Ford, Mike [LSS]
On 13 January 2004 15:10, Sebastian Ossio wrote:

 Hi,
 
 I´m trying to give an empty reference as a parameter, in a
 function. Or
 rather make a parameter that is a reference optional.
 
 I have a function that should react differently if it is
 given an object
 or not. It works, but it gives me a warning that the second
 argument is
 not being given obviously.
 
 Sadly I cannot make the parameter optional in the function definition
 because mine has to be a reference. One can´t do such a thing as
 
 function( $parameter1,  objectparameter = NULL)
 
 this results into a parsing error.
 
 I cannot believe that there is no way of making an object parameter
 optional. 
 
 So tell me please what I´m missing.

PHP5 ;).  This is one of the improvements that will be in PHP 5 when it is
released.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



[PHP] Re: PHP XML Reference

2003-03-14 Thread Alexandru COSTIN
Hello,
You will also might want to try the free Krysalis platform - it's
designed from scratch for XML/XSL content publishing (a la Cocoon) and you
will find it very useful for your goals.

http://www.interakt.ro/products/Krysalis/



Alexnadru

--
Alexandru COSTIN
Chief Operating Officer
http://www.interakt.ro/
+4021 411 2610
Tim Funk [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 Hi,

 I am new to PHP, however i have a good handle on C programming and
therefore hope to apply those conceps to PHP programming quickly. I am
looking for a print reference that can help me to construct a web-based
front-end for an application using XML. Any help in this regard will bemuch
appreciated.

 Thanks,
 Tim



 -
 Do you Yahoo!?
 Yahoo! Web Hosting - establish your business online



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



[PHP] Re: PHP XML Reference

2003-03-14 Thread David Eisenhart
check out the book XML and PHP by Vikram Vaswani, News Riders; a well
written and concise treatment of xml and php.

David Eisenhart



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



[PHP] PHP XML Reference

2003-03-13 Thread Tim Funk

Hi,

I am new to PHP, however i have a good handle on C programming and therefore hope to 
apply those conceps to PHP programming quickly. I am looking for a print reference 
that can help me to construct a web-based front-end for an application using XML. Any 
help in this regard will bemuch appreciated.

Thanks,
Tim



-
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online

Re: [PHP] PHP XML Reference

2003-03-13 Thread Javagal S Reddy
Hi Tim,

I have used the big ass Professional PHP 4 XML book from Wrox 
for the last 6 months, and i have picked up immense knowledge from 
that resource. Infact i have gone up in my career to being the 
lead web developer in my team...and i must atribute it to this 
book.

You can find more information here:

http://www.amazon.com/exec/obidos/ASIN/1861007213/qid%3D1047628025/sr%3D11-1/ref%3Dsr%5F11%5F1/002-9385423-3309610

Good luck,
-Javagal
On Fri, 14 Mar 2003 Tim Funk wrote :
Hi,

I am new to PHP, however i have a good handle on C programming 
and therefore hope to apply those conceps to PHP programming 
quickly. I am looking for a print reference that can help me to 
construct a web-based front-end for an application using XML. Any 
help in this regard will bemuch appreciated.

Thanks,
Tim


-
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
___
Odomos - the only  mosquito protection outside 4 walls -
Click here to know more!
http://r.rediff.com/r?http://clients.rediff.com/odomos/Odomos.htmodomoswn
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] By reference

2003-02-13 Thread Chris Boget
I thought I understood this but evidently not...  
Consider the following:

$firstVar = 123ABC;

$secondVar = $firstVar;
$thirdVar = $firstVar;

echo $secondVar;
echo 'br';
echo $thirdVar;

When I echo $secondVar, I get '0' but when I echo $thirdVar,
I get the value of $firstVar.

Why?  I thought that = made it so that the left operand was
pointing to the memory location of the right?

Chris



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





Re: [PHP] By reference

2003-02-13 Thread Chris Wesley
On Thu, 13 Feb 2003, Chris Boget wrote:

 $firstVar = 123ABC;

 $secondVar = $firstVar;

= is a bitwise AND, and an assignment.
This didn't do what you expected it to do.

 $thirdVar = $firstVar;

= is a reference assignment.
This did what you expected it to do.

 Why?  I thought that = made it so that the left operand was
 pointing to the memory location of the right?

You make the left operand point to the memory location of the right
operand with =.  = is the only reference assignment available, besides
passing/returning by reference with functions.

$stuff = 1234;
$ref = $stuff;// $ref points to $stuff's data
print $ref . \n; // prints 1234
$stuff = 5678;
print $ref . \n; // prints 5678

hth,
~Chris


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




[PHP] php reference behavior

2002-12-17 Thread 22 manopohuji

hi, i'm running into some weird behavior with php references.  i
distilled it down to some test code below:

?php

$array  =  array( 'name' = 'dean' );

$var1['arrayref']  =   $array;

$var2  =  $var1;

echo var1:\n;
print_r( $var1 );

echo var2:\n;
print_r( $var2 );

$var1['arrayref']  =  NULL;

echo var1:\n;
print_r( $var1 );

echo var2:\n;
print_r( $var2 );

?

it seems that setting a hash key to a reference to something, and then
repointing that key to NULL, apparently sets the original 'something' to
NULL instead of just 'repointing' the hash key!  am i missing something
obvious here, or is this behavior not what you'd normally expect?  i
wrote similar code in perl, and it behaved as i expected: the second
hash still pointed to the original target (i am almost certain c/c++ and
java also behave this way).  so what is going on with php?  does anyone
know how to get it to do what i want it to do --  i.e., merely unset the
key mapping of one of the hashes, leaving the other hash still pointing
at the target?  thansk for any insight you might be able to give!

xomina





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




[PHP] variable reference parameters

2002-08-29 Thread Timo Ewalds

I've created (with help from some code from the site) a function to make
strings or arrays mysql safe. It works just fine, assuming you pass your
variables by reference ( sqlSafe($var) ), but I get this error every time
it is used:

[error] 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 [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 file.php on line X

I want the function to be able to accept as many variables as needed to make
them sqlsafe (10 is enough for now), and to remove that annoying error, I'd
also like to not need to pass them by reference. Is this possible?? and if
so, how?? I know it is possible to add the  before each function parameter,
but then I can't pass more or less variables than I put in the function
definition, cause you can't have default values for a reference parameter
(go figure), and it'll also complain if you give it too few variables.

function sqlSafe( $a0,
 $a1=NULL,
 $a2=NULL,
 $a3=NULL,
 $a4=NULL,
 $a5=NULL,
 $a6=NULL,
 $a7=NULL,
 $a8=NULL,
 $a9=NULL){
 if(func_num_args()10)
  echo h1Too Many Args in sqlSafe/h1;
 for($i=0;$ifunc_num_args();$i++){
  $name=a . $i;
  if(!isset($$name)) continue;
  if(is_array($$name)){
   foreach($$name as $n = $v){
if(is_array($v))
 sqlSafe(${$name}[$n]);
elseif(isset($v))
 ${$name}[$n] = mysql_escape_string ($v);
   }
  }else
   $$name = mysql_escape_string ($$name);
 }
}



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




Re: [PHP] variable reference parameters

2002-08-29 Thread DL Neil

Timo,

If you use func_num_args() to ascertain the number of arguments passed to
the function and func_get_arg() to retrieve each argument in turn (from a
list of unstated length), will that do the trick?

Regards,
=dn



 I've created (with help from some code from the site) a function to make
 strings or arrays mysql safe. It works just fine, assuming you pass your
 variables by reference ( sqlSafe($var) ), but I get this error every time
 it is used:

 [error] 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 [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 file.php on line X

 I want the function to be able to accept as many variables as needed to
make
 them sqlsafe (10 is enough for now), and to remove that annoying error,
I'd
 also like to not need to pass them by reference. Is this possible?? and if
 so, how?? I know it is possible to add the  before each function
parameter,
 but then I can't pass more or less variables than I put in the function
 definition, cause you can't have default values for a reference parameter
 (go figure), and it'll also complain if you give it too few variables.

 function sqlSafe( $a0,
  $a1=NULL,
  $a2=NULL,
  $a3=NULL,
  $a4=NULL,
  $a5=NULL,
  $a6=NULL,
  $a7=NULL,
  $a8=NULL,
  $a9=NULL){
  if(func_num_args()10)
   echo h1Too Many Args in sqlSafe/h1;
  for($i=0;$ifunc_num_args();$i++){
   $name=a . $i;
   if(!isset($$name)) continue;
   if(is_array($$name)){
foreach($$name as $n = $v){
 if(is_array($v))
  sqlSafe(${$name}[$n]);
 elseif(isset($v))
  ${$name}[$n] = mysql_escape_string ($v);
}
   }else
$$name = mysql_escape_string ($$name);
  }
 }



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




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




Fw: [PHP] variable reference parameters

2002-08-29 Thread Kevin Stone

Timo,

 This is just an idea.  How about using the get_defined_vars() function,
 extracting the desired user defined variables, storing them in one array,
 and then sending that array as the single parameter to your sqlSafe()
 function?

 http://www.php.net/manual/en/function.get-defined-vars.php

 Good luck,
 Kevin


 - Original Message -
 From: Timo Ewalds [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, August 27, 2002 11:21 PM
 Subject: [PHP] variable reference parameters


  I've created (with help from some code from the site) a function to make
  strings or arrays mysql safe. It works just fine, assuming you pass your
  variables by reference ( sqlSafe($var) ), but I get this error every
time
  it is used:
 
  [error] 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 [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 file.php on line X
 
  I want the function to be able to accept as many variables as needed to
 make
  them sqlsafe (10 is enough for now), and to remove that annoying error,
 I'd
  also like to not need to pass them by reference. Is this possible?? and
if
  so, how?? I know it is possible to add the  before each function
 parameter,
  but then I can't pass more or less variables than I put in the function
  definition, cause you can't have default values for a reference
parameter
  (go figure), and it'll also complain if you give it too few variables.
 
  function sqlSafe( $a0,
   $a1=NULL,
   $a2=NULL,
   $a3=NULL,
   $a4=NULL,
   $a5=NULL,
   $a6=NULL,
   $a7=NULL,
   $a8=NULL,
   $a9=NULL){
   if(func_num_args()10)
echo h1Too Many Args in sqlSafe/h1;
   for($i=0;$ifunc_num_args();$i++){
$name=a . $i;
if(!isset($$name)) continue;
if(is_array($$name)){
 foreach($$name as $n = $v){
  if(is_array($v))
   sqlSafe(${$name}[$n]);
  elseif(isset($v))
   ${$name}[$n] = mysql_escape_string ($v);
 }
}else
 $$name = mysql_escape_string ($$name);
   }
  }
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 



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




Re: [PHP] Object Reference Serialization

2002-05-03 Thread Adam Langley

OK, heres all the code...

I have a BoundForm class, a BoundFormPage class, and a BoundTextField...

I create a BoundForm, add a BoundFormPage object to it, then add a
BoundTextField to the BoundFormPagethen I add the root node (the
BoundForm) to the SESSION...

The Form, and Page survive serialization, but not the TextField...I dont
know why.



// these are the class definitions

class BoundTextField{

var $name;

var $value;

function BoundTextField($name, $size, $value=){

$this-name = $name;

print input type=\text\ name=\$name\ value=\.addSlashes($name).\
/input\n;

}


function isValid(){

if (strlen(trim($value))0){

return true;

} else {

return false;

}

}

}

class BoundForm{

function BoundForm($lName){

$name = $lName;

print count = .count($pages);

}

var $action;

var $method;

var $name;


var $dbName;


var $pages;



// upon instantiation, write form to session object.


function addPage($page){

if (!isset($this-pages[$page-name])){

print adding pagebr;

$this-pages[$page-name] = $page;

} else {

// this page already exists, so we dont want to replace it,

// or it will lose all its stored data...

print  .$this-pages[$page-name]-name. already existsbr\n;

}

}

}

class BoundFormPage{

// these are the fields (BoundFormElements) that you can add to a form page.

var $fields;

var $name;


function BoundFormPage($lName){


$this-name = $lName;

//$myTextField = new BoundTextField(No, 30);

}

// will determine if the page has been successfully filled in.

function isComplete(){

for(reset($fields);$key = key($fields);next($fields)){

if (!$fields[$key].isValid()){

return false;

}

}

}

function addField($field){

print $field-name;

print b.count($this-fields)./b;

if (!isset($this-fields[$field-name])){

print(adding field .$field-name);

$this-fields[$field-name] = $field;

} else {

// this page already exists, so we dont want to replace it,

// or it will lose all its stored data...

print already exists.$this-fields[$field-name]-name.br\n;

}

}

}

//--

//and this code execute the sample classes above...

// get our form object back, but dont overwrite it

if (!session_is_registered(myForm)){

$myForm = new BoundForm(Application Form);

session_register(myForm);

} else {

//return $_SESSION[$formName];

session_register(myForm);

}

// construct the hierachy (note that all 'add' methods will not overwrite
existing children of same names)

$firstPage = new BoundFormPage(pageOne);

//$myTextField2 = new BoundTextField(gumber, 30);

//$firstPage-fields[$myTextField2-name] = $myTextField2;

$myTextField = new BoundTextField(CustomerNumber, 30);

$firstPage-addField($myTextField);

$myForm-addPage($firstPage);

Thies C. Arntzen [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...

 On Fri, May 03, 2002 at 12:34:01AM +1200, Adam Langley wrote:

  Hi everyone,

 

  Im trying to store an object which contains an associative array of
classes,

  each of which contains an array of classes, so a 3-tier hierachy, in the

  session object. However, the final tier gets lost upon

  serialization/deserialization, why is this and how can I prevent this
from

  happening?



 send us a minimal testcase...

 tc



 

  Thanks in advance.

 

  - Adam Langley

 

 

 

  --

  PHP General Mailing List (http://www.php.net/)

  To unsubscribe, visit: http://www.php.net/unsub.php




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




Re: [PHP] Object Reference Serialization

2002-05-03 Thread Adam Langley

No worries...I just realized that my object never repopulated the underlying
classes with previous object references...Thanks guys, but I see my problem
now...

Cheers.

Adam Langley.


Thies C. Arntzen [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Fri, May 03, 2002 at 12:34:01AM +1200, Adam Langley wrote:
  Hi everyone,
 
  Im trying to store an object which contains an associative array of
classes,
  each of which contains an array of classes, so a 3-tier hierachy, in the
  session object. However, the final tier gets lost upon
  serialization/deserialization, why is this and how can I prevent this
from
  happening?

 send us a minimal testcase...
 tc

 
  Thanks in advance.
 
   - Adam Langley
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php



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




Re: [PHP] Object Reference Serialization

2002-05-02 Thread Thies C. Arntzen

On Fri, May 03, 2002 at 12:34:01AM +1200, Adam Langley wrote:
 Hi everyone,
 
 Im trying to store an object which contains an associative array of classes,
 each of which contains an array of classes, so a 3-tier hierachy, in the
 session object. However, the final tier gets lost upon
 serialization/deserialization, why is this and how can I prevent this from
 happening?

send us a minimal testcase...
tc

 
 Thanks in advance.
 
  - Adam Langley
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

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




[PHP] Object reference

2002-03-21 Thread Lucijan

I can't understand why this works like it does.

class MyObj {
  var $Name;
  function MyObj($Name) {
$this-Name = $Name;
  }
}
$a = new MyObj('MyObjName');
$b = $a;
$b-Name = 'NoName';
echo $a-Name;

Last line will output 'MyObjName' instead of 'NoName' (like I was expecting)
I'd expect $a and $b to behave like reference pointers (change in $b is
reflected in $a and vice versa) instead of copiing $a to $b (beiing a Delphi
programmer this is as natural to me as the Sun raising in east and setting
in west :-)

So, is there a way to do this; pointers or something maybe?

Lucijan



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




RE: [PHP] Object reference

2002-03-21 Thread Stampe, Lars

Hi,

Use  to reference one variable to another!

$b = $a;

Lars

-Original Message-
From: Lucijan [mailto:[EMAIL PROTECTED]]
Sent: 21 March 2002 10:20
To: [EMAIL PROTECTED]
Subject: [PHP] Object reference


I can't understand why this works like it does.

class MyObj {
  var $Name;
  function MyObj($Name) {
$this-Name = $Name;
  }
}
$a = new MyObj('MyObjName');
$b = $a;
$b-Name = 'NoName';
echo $a-Name;

Last line will output 'MyObjName' instead of 'NoName' (like I was expecting)
I'd expect $a and $b to behave like reference pointers (change in $b is
reflected in $a and vice versa) instead of copiing $a to $b (beiing a Delphi
programmer this is as natural to me as the Sun raising in east and setting
in west :-)

So, is there a way to do this; pointers or something maybe?

Lucijan



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

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




Re: [PHP] Object reference

2002-03-21 Thread Lucijan

 Use  to reference one variable to another!
 $b = $a;

Thanks.

Lucijan



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




[PHP] javascript reference (slightly ot)

2001-08-14 Thread Christian Dechery

Sorry for the OT but, but I'm struggling to get my forms to have a good 
validation in JavaScript.

Does anyone know a complete reference to JavaScript, like, with all 
objects, it's functions, parameters and etc...

that would help a lot..

Thanks...

. Christian Dechery (lemming)
. http://www.tanamesa.com.br
. Gaita-L Owner / Web Developer


-- 
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] javascript reference (slightly ot)

2001-08-14 Thread Evan Nemerson

I used Netscape's javascript reference when I started, but I also found that 
looking at source code (javascripts.com used to be good) helped alot.

http://developer.netscape.com/docs/manuals/communicator/jsref/index.htm





On Tuesday 14 August 2001 18:58, you wrote:
 Sorry for the OT but, but I'm struggling to get my forms to have a good
 validation in JavaScript.

 Does anyone know a complete reference to JavaScript, like, with all
 objects, it's functions, parameters and etc...

 that would help a lot..

 Thanks...
 
 . Christian Dechery (lemming)
 . http://www.tanamesa.com.br
 . Gaita-L Owner / Web Developer

-- 
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] Bug: reference, foreach, array (FYI)

2001-02-21 Thread Yasuo Ohgaki

I've found out what's wrong with PHP4 partially.
It might help people who are getting errors - document contains no data or 
like.

You may get various strange PHP4 behavior with (possibly without) 
combination of reference, foreach and array if you don't pass expected 
values to functions.

I've posted Bug Report to www.php.net BugID#9369

Take a look at comments in test2.php

--
Yasuo Ohgaki

Previous Post was Re: [PHP] Strange behavior: Cannot exit as expected AND 
Script starts from the beginning, executed TWICE. Anyone?

[If you have comments on this please send e-mail to me]

I think PHP4.0.4pl1 has unsafe code for 8bit char codes. I suspect PHP4 
does
this:

PHP4 behavior: Script is executed TWICE and included file is not processed
1) PHP parse script and start executing.
- The script check username data in db, if there is the same username,
return error. If not, insert new username into db.
2) PHP encounters 8bit char unclean code some where near include() and
restart script execution from the beginning for some reason.
- The script written to include() file for successful user 
registration.

PHP inserts new username into db at 1st execution, then it finds the same
username in db and return error for 2nd execution. If I put die('died 
here')
BEFORE include(), PHP stops execution and outputs 'died here'. but not 
AFTER
include(). I was using 'ob_gzhandler', disabling it does not make
difference.

This happened when user registration check/insert was done in function
defined in included file. PHP also does not log any errors.

PHP4 behavior: Script does not process included file and outputs default
HTML.
1) PHP parse script and start executing.
2) PHP encounters 8bit char unclean code some where near include(), and
outputs default HTML for null output and stops execution for some reason.

Therefore, I can see output from die('died here') if I put BEFORE 
include(),
but not AFTER include().

This happened when user registration check/insert was done in the script
itself. The script logic is identical.  PHP does not log any errors.

I use EUC (Extended Unix Code), EUC-JP to be specific,  for char code, 
which
is supposed to work well with 8bit char code clean programs.

[Environment]
OS: RadHat Linux7.0.1/ja(i386) FTP version (no glibc update)
Apache: Apache 1.3.17 w/ mod_ssl-2.8.0, mod_gzip-1.13.17a. build from 
source
PHP: PHP4.0.4pl1 w/ pgsql-7.0.3, gd-1.8.3, mhash, mcript and others. build
from source.
  - ECU-JP for all html,  php scripts
PHP Configure:
'./configure' '--with-apxs' '--disable-short-tags' '--enable-bcmath'
'--with-zlib-dir' '--enable-ftp' '--with-imap' '--with-mhash'
'--with-mcrypt' '--with-pgsql' '--with-swf' '--enable-sysvsem'
'--enable-sysvshm' '--with-zlib' '--enable-iconv' '--with-kakasi'
'--enable-jstring' '--enable-mbregex' '--with-namazu'
'--with-gd=../gd-1.8.3/' '--with-jpeg-dir=/usr' '--with-xpm-dir=/usr/X11R6'

I cannot think of any reasonable explanation for this strange PHP4 behavior
other than possibility that glibc has bugs. (8bit char unsafe code, etc. I
haven't research about my exact glibc version nor bugs yet.)

Any comments appreciated.

--
Yasuo Ohgaki


--
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]


_
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.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]