[PHP] Is this a bug ?

2001-02-05 Thread Sébastien ROZIER

Hello,
when I use this syntax:
champs[0] is a string, which is the name of an HTML form variable.

class test
   {
   var champs;

   function verif()
   {
   for ($i = 0; $i < count($this->champs) ; $i++)
   {
   global $$this->champs[$i][0];
   $tmp = $this->champs[$i][0];
   $this->champs[$i][1] = $$tmp;
   }
   }
   }

Everything works properly, but when I use this :
class test
   {
   var champs;

   function verif()
   {
   for ($i = 0; $i < count($this->champs) ; $i++)
   {
global $$this->champs[$i][0];
$this->champs[$i][1] = $$this->champs[$i][0];
   }
   }
   }

It doesn't work ($this->champs[$i][1] is empty).
My problem is : why is the global instruction working whereas the newt 
line isn't with this formulation (I have to use a temporary variable 
which I then can reference).
Thanx for any help, and apologize my poor English.
S. ROZIER


-- 
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] Is this a bug?

2002-05-27 Thread zhaoxd

Hello all:

Not long ago I wrote some php code in my computer which had a apache server,and my 
php version is 4.0.5.The code as followed:

$num = 2886732778;
settype($num, integer);
echo $num;

And I found the num is -2147483648.attention,please:the version of php is 4.0.5.

When I installed php-4.2.0 in my computer,however,I found the output of result is 
-1408234499.

Why did the difference between the two version php happen?Is this a bug???

Any help is appreciated!
zhaoxd





[PHP] Is this a BUG?

2002-06-23 Thread César Aracena

Hi all,
 
A couple of days ago, I’ve been starting to organize all my scripts into
functions within libraries, and got into a problem this morning. Now, I
don’t know if this is a bug or it’s just me getting confused. I got the
problem when calling two functions – one gets variables from the other –
within the same page.
 
That is, I have a mainusers.php page, which only calls for functions
instead of writing them all together inside that page. At one step, it
calls for an “adduser” function which brings a table that let the
administrator insert a new user. After the submit button is pressed, it
calls for a function called “useradded” which resides in the same
library as the “adduser” function. This useradded function queries the
database, inserting the user. The problem is that it does not get the
HTTP_POST_VARS although they are being passed according to phpinfo.php.
 
The structure is this:
 
Project directory
 
>Library Directory
>>addlib.php
>>>adduser() function
>>>useradded() function
 
>Pages directory
>>mainusers.php
>>>first calls for adduser()
>>>and then for useradded()
 
Now, the thing is if I, instead of calling the function, write the query
directly in the mainusers.php page, the variables are get well and
written into the database. I don’t know if this makes much sense, but
the thing is… Isn’t PHP forced to pass those variables before the
function is called so when they’re needed they can be get through
HTTP_POST_VARS or just $var_name which I like using?
 
Thanks…
 
Cesar Aracena  
CE / MCSE+I
Neuquen, Argentina
+54.299.6356688
+54.299.4466621
 



[PHP] Is this a bug?

2001-08-15 Thread Stig Nørgaard Jepsen

Hello,

I have this code, which is a cooked down code of something bigger. So don't
ask what it's for.
The problem is that I can't get this script working the way I like it at
all. Maybe it's a bug. Maybe you have another suggestion?
Somewhere in the middle section i have wrote test1 and test2 as a comment.
If you activate test2 instead of test1, then you will have some output(not
the expected output), else I just see a page saying:"The page cannot be
displayed".

I think it's very strange, any ideas?
Try inserting this into a file and try yourself.

/Stig

"; //
//echo "" . $newarray[0] . "-newarray"; //test2
echo $newarray[0] . "-newarray"; //test1
};

$row = array
("A"=>"1","B"=>"1","C"=>"1","D"=>"1","E"=>"1","F"=>"1","Z"=>"1");
array_walk ($row, 'grabkeys', $side);
array_walk ($row, 'showkeys');
?>



-- 
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] Is this a bug?

2001-08-20 Thread Ratko

Please try this:


I get "true" as a result. How's that possible?
But if I do:
echo "996448234192168122"==="996448234192168125";
then I get "false" as expected.

php 4.0.6, Debian Potatoe Linux.

Does this happen only on my computer?


thanks,
ratko


-- 
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] is this a bug?

2007-08-19 Thread Augusto Morais

I dont know what is happening...


Can somebody clarify the situation for me?


here is the situation:

  i have 3 files:

class.php
foo.php
bar.php

// - class.php
class globalactions {

 function include_file($module) {
if ($module) {
return 
("modules/".$module."/templates/".$module.".php");
} else { return include("modules/main/templates/index.php"); }
 }
}


// - foo.php
include "lib/clients.class.php";
$clients = new clients(); //instatiating the clients class


// - bar.php
include 'class.php';
$globalactions = new globalactions ();
include $globalactions->include_file("foo");  //return ->
"modules/foo/templates/foo.php"

var_dump($clients); //will return the object



OK. All this works. but i want make some changes.

Well.. What i want to do is this:

class.php:

change the line:
return ("modules/".$module."/templates/".$module.".php");

to:
return include ("modules/".$module."/templates/".$module.".php");

and in the bar.php:


// - bar.php
include 'class.php';
$globalactions = new globalactions ();
$globalactions->include_file("foo");  //return -> "include
modules/foo/templates/foo.php"  // OK. This works.

var_dump($clients); //i dont get the object here. I got NULL!!! why?!?!!?



What is happening?

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



[PHP] Is this a bug?

2008-08-29 Thread Catalin Zamfir Alexandru, DATAGRAM SRL
Hello guys,

I've been stalking on the list for some time. Didn't have
anything to report/talk, until now. I have a code like this, maybe you guys
can reproduce it, with output buffering started:

Echo 'something';

Echo 'another thing';

Echo 'something '\;

 

What happens is that ANYTHING that was echo'ed until that \,
will not reach the buffer. Although, this should actually be a Parse Error,
it isn't, it just echoes what was echoed after the god damned \. It took me
two hours to find this typo in the code .

 

Can you guys reproduce the error? I can actually give you a
link to the server where this code runs.



[PHP] IS THIS A BUG?

2003-08-27 Thread Steve Todd
Is it possible to define a variable, such as:
$foo = "bar";
 
and then do as follows to create a totally different variable:
$$foo =  "text here";
 
this seems to mean $bar = "text here";.
 
Is this a bug or can we legally use it.
 
Steve


[PHP] Is this a bug?

2005-01-13 Thread Rory McKinley
Hi
Probably a trivial question
While trying to use mysqli on my dev machine, PHP returns the following:
Fatal error: Trying to clone an uncloneable object of class mysqli
After STFW I have found a solution that involves swiching off 
compatibility with Zend Engine 1 in php.ini.

However, after going to bugs.php.net, it seems that it has not been 
logged as a bug.

So, the question would be - do I log it or am I wasting their time?
--
Rory McKinley
Nebula Solutions
+27 21 555 3227 - office
+27 21 551 0676 - fax
+27 82 857 2391 - mobile
www.nebula.co.za

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


Re: [PHP] Is this a bug ?

2001-02-05 Thread Steve Werby

"Sébastien ROZIER" <[EMAIL PROTECTED]> wrote:
> when I use this syntax:
> champs[0] is a string, which is the name of an HTML form variable.
>
> class test
>{
>var champs;

When initiating a variable you need to prefix it with "$". So the line above
should be:

var $champs;

If it's an array you may want to initiate it like:

var $champs = array();

I don't have the time to analyze your code in full right now, but hopefully
this will get you started.

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.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]




Re: [PHP] Is this a bug ?

2001-02-05 Thread Sébastien ROZIER

OK sorry, I did put the "$", and adding = array() is still not working
Thanx for any help

Steve Werby wrote:

> "Sébastien ROZIER" <[EMAIL PROTECTED]> wrote:
> 
>> when I use this syntax:
>> champs[0] is a string, which is the name of an HTML form variable.
>> 
>> class test
>>{
>>var champs;
> 
> 
> When initiating a variable you need to prefix it with "$". So the line above
> should be:
> 
> var $champs;
> 
> If it's an array you may want to initiate it like:
> 
> var $champs = array();
> 
> I don't have the time to analyze your code in full right now, but hopefully
> this will get you started.
> 
> --
> Steve Werby
> COO
> 24-7 Computer Services, LLC
> Tel: 804.817.2470
> http://www.247computing.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]




Re: [PHP] Is this a bug?

2002-05-27 Thread Jule

Dunno if it's a bug, but it's 2147483648 to max for an integer? doesn't 
bigint support higher numbers than that?
i'm not sure but i think that's why your number gor cut down.

Jule 
On Monday 27 May 2002 22:36, zhaoxd wrote:
> Hello all:
> 
> Not long ago I wrote some php code in my computer which had a apache
> server,and my php version is 4.0.5.The code as followed:
> 
> $num = 2886732778;
> settype($num, integer);
> echo $num;
> 
> And I found the num is -2147483648.attention,please:the version of
> php is 4.0.5.
> 
> When I installed php-4.2.0 in my computer,however,I found the output
> of result is -1408234499.
> 
> Why did the difference between the two version php happen?Is this a
> bug???
> 
> Any help is appreciated!
> zhaoxd
> 
> 

-- 
|\/\__/\/|
|   Jule Slootbeek   |
|   [EMAIL PROTECTED]|
|   http://blindtheory.cjb.net   |
|   __   |
|/\/  \/\|

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




Re: [PHP] Is this a bug?

2002-05-27 Thread Jule

ps: sorry for all the typos...

Jule
On Monday 27 May 2002 22:51, Jule wrote:
> Dunno if it's a bug, but it's 2147483648 to max for an integer? doesn't
> bigint support higher numbers than that?
> i'm not sure but i think that's why your number gor cut down.
>
> Jule
>
> On Monday 27 May 2002 22:36, zhaoxd wrote:
> > Hello all:
> >
> >
> >
> > Not long ago I wrote some php code in my computer which had a apache
> >
> > server,and my php version is 4.0.5.The code as followed:
> >
> >
> >
> > $num = 2886732778;
> >
> > settype($num, integer);
> >
> > echo $num;
> >
> >
> >
> > And I found the num is -2147483648.attention,please:the version of
> >
> > php is 4.0.5.
> >
> >
> >
> > When I installed php-4.2.0 in my computer,however,I found the output
> >
> > of result is -1408234499.
> >
> >
> >
> > Why did the difference between the two version php happen?Is this a
> >
> > bug???
> >
> >
> >
> > Any help is appreciated!
> >
> > zhaoxd

-- 
|\/\__/\/|
|   Jule Slootbeek   |
|   [EMAIL PROTECTED]|
|   http://blindtheory.cjb.net   |
|   __   |
|/\/  \/\|

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




Re: [PHP] Is this a bug?

2002-05-27 Thread Jule

see this page:

http://www.php.net/manual/en/language.types.integer.php

Jule

On Monday 27 May 2002 22:52, Jule wrote:
> ps: sorry for all the typos...
>
> Jule
>
> On Monday 27 May 2002 22:51, Jule wrote:
> > Dunno if it's a bug, but it's 2147483648 to max for an integer? doesn't
> > bigint support higher numbers than that?
> > i'm not sure but i think that's why your number gor cut down.
> >
> > Jule
> >
> > On Monday 27 May 2002 22:36, zhaoxd wrote:
> > > Hello all:
> > >
> > >
> > >
> > > Not long ago I wrote some php code in my computer which had a
> > > apache
> > >
> > > server,and my php version is 4.0.5.The code as followed:
> > >
> > >
> > >
> > > $num = 2886732778;
> > >
> > > settype($num, integer);
> > >
> > > echo $num;
> > >
> > >
> > >
> > > And I found the num is -2147483648.attention,please:the version of
> > >
> > > php is 4.0.5.
> > >
> > >
> > >
> > > When I installed php-4.2.0 in my computer,however,I found the
> > > output
> > >
> > > of result is -1408234499.
> > >
> > >
> > >
> > > Why did the difference between the two version php happen?Is this a
> > >
> > > bug???
> > >
> > >
> > >
> > > Any help is appreciated!
> > >
> > > zhaoxd

-- 
|\/\__/\/|
|   Jule Slootbeek   |
|   [EMAIL PROTECTED]|
|   http://blindtheory.cjb.net   |
|   __   |
|/\/  \/\|

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




Re: [PHP] Is this a BUG?

2002-06-23 Thread Andrew Brampton

If the code is in a function then don't you need to call
global $HTTP_POST_VARS;
at the top of the function so that it knows you can use that varible?

Andrew
- Original Message -
From: "César Aracena" <[EMAIL PROTECTED]>
To: "PHP General List" <[EMAIL PROTECTED]>
Sent: Sunday, June 23, 2002 11:06 PM
Subject: [PHP] Is this a BUG?


Hi all,

A couple of days ago, I've been starting to organize all my scripts into
functions within libraries, and got into a problem this morning. Now, I
don't know if this is a bug or it's just me getting confused. I got the
problem when calling two functions - one gets variables from the other -
within the same page.

That is, I have a mainusers.php page, which only calls for functions
instead of writing them all together inside that page. At one step, it
calls for an "adduser" function which brings a table that let the
administrator insert a new user. After the submit button is pressed, it
calls for a function called "useradded" which resides in the same
library as the "adduser" function. This useradded function queries the
database, inserting the user. The problem is that it does not get the
HTTP_POST_VARS although they are being passed according to phpinfo.php.

The structure is this:

Project directory

>Library Directory
>>addlib.php
>>>adduser() function
>>>useradded() function

>Pages directory
>>mainusers.php
>>>first calls for adduser()
>>>and then for useradded()

Now, the thing is if I, instead of calling the function, write the query
directly in the mainusers.php page, the variables are get well and
written into the database. I don't know if this makes much sense, but
the thing is. Isn't PHP forced to pass those variables before the
function is called so when they're needed they can be get through
HTTP_POST_VARS or just $var_name which I like using?

Thanks.

Cesar Aracena <mailto:[EMAIL PROTECTED]>
CE / MCSE+I
Neuquen, Argentina
+54.299.6356688
+54.299.4466621




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




Re: [PHP] Is this a bug?

2001-08-20 Thread ERISEN, Mehmet Kamil

you are right.


I tested with 99644xxx and 964 It printed A. 
However, if you are down to 644xxx is prints B which is
correct. Perhaps a limitation of 16 digits.
?
good catch
--- Ratko <[EMAIL PROTECTED]> wrote:
> Please try this:
>  echo "996448234192168122"=="996448234192168125";
> ?>
> 
> I get "true" as a result. How's that possible?
> But if I do:
> echo "996448234192168122"==="996448234192168125";
> then I get "false" as expected.
> 
> php 4.0.6, Debian Potatoe Linux.
> 
> Does this happen only on my computer?
> 
> 
> thanks,
> ratko
> 
> 
> -- 
> 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]
> 


=
Mehmet Erisen
http://www.erisen.com

__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.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]




RE: [PHP] Is this a bug?

2001-08-20 Thread Mark Roedel

> -Original Message-
> From: Ratko [mailto:[EMAIL PROTECTED]] 
> Sent: Monday, August 20, 2001 1:40 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Is this a bug?
> 
> 
> Please try this:
>  echo "996448234192168122"=="996448234192168125";
> ?>
> 
> I get "true" as a result. How's that possible?
> But if I do:
> echo "996448234192168122"==="996448234192168125";
> then I get "false" as expected.

A couple of snippets from the PHP manual:

http://www.php.net/manual/en/language.types.integer.php:
"The size of an integer is platform-dependent, although a maximum value
of about two billion is the usual value (that's 32 bits signed)...If you
specify a number beyond the bounds of the integer type, it will be
interpreted as a float instead"

...and...

http://www.php.net/manual/en/language.types.float.php
"The size of a float is platform-dependent, although a maximum of
~1.8e308 with a precision of roughly 14 decimal digits is a common
value...Never trust floating number results to the last digit, and never
compare floating point numbers for equality.  If you really need higher
precision, you should use the arbitrary precision math functions or gmp
functions instead."


---
Mark Roedel   | "Blessed is he who has learned to laugh
Systems Programmer|  at himself, for he shall never cease
LeTourneau University |  to be entertained."
Longview, Texas, USA  |  -- John Powell 

--
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] is this a bug?

2007-08-20 Thread Tijnema
On 8/20/07, Augusto Morais <[EMAIL PROTECTED]> wrote:
> I dont know what is happening...
>
>
> Can somebody clarify the situation for me?
>
>
> here is the situation:
>
>   i have 3 files:
>
> class.php
> foo.php
> bar.php
>
> // - class.php
> class globalactions {
>
>  function include_file($module) {
>if ($module) {
>return 
> ("modules/".$module."/templates/".$module.".php");
>} else { return include("modules/main/templates/index.php"); }
>  }
> }
>
>
> // - foo.php
> include "lib/clients.class.php";
> $clients = new clients(); //instatiating the clients class
>
>
> // - bar.php
> include 'class.php';
> $globalactions = new globalactions ();
> include $globalactions->include_file("foo");  //return ->
> "modules/foo/templates/foo.php"
>
> var_dump($clients); //will return the object
>
>
>
> OK. All this works. but i want make some changes.
>
> Well.. What i want to do is this:
>
> class.php:
>
> change the line:
> return ("modules/".$module."/templates/".$module.".php");
>
> to:
> return include ("modules/".$module."/templates/".$module.".php");
>
> and in the bar.php:
>
>
> // - bar.php
> include 'class.php';
> $globalactions = new globalactions ();
> $globalactions->include_file("foo");  //return -> "include
> modules/foo/templates/foo.php"  // OK. This works.
>
> var_dump($clients); //i dont get the object here. I got NULL!!! why?!?!!?
>
>
>
> What is happening?
>

This is because in the second example, you're including the file in a
different scope than the first example. The file included (and so all
variables etc. declared in it) will be added to the scope where the
include is.

This manual page should help you:
http://www.php.net/manual/en/language.variables.scope.php

Tijnema
-- 
If this is a mailing list: DO NOT TOP POST! why?:
http://www.caliburn.nl/topposting.html

Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

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



Re: [PHP] is this a bug?

2007-08-20 Thread Tijnema
On 8/20/07, aflavio <[EMAIL PROTECTED]> wrote:
>
> Strange..
>
> I'm return a include..

Not exactly... you're returning the return value of an include.

Take this:
var.php:

foo.php

> the file will be included in the scope of the class? Because this i cant use 
> the variables declared in the file ? all declared in the file only can be 
> access from the method that i use to include the class file.
>
> example:
>

>
>
> Am i right?
>
> thanks
>
> ps.: Sorry by the english.
>
> Augusto Morais
>
Well, you're quite close, but you expect something different from the
return... Like I said above.

Tijnema

ps. I don't really care about your english, but top posting is
annoying. Read the site in my signature to know why. Also snipping
irrelevant parts of the original message is important.

pps. Make sure you use the "Reply to all" button when making a reply
to the list, as for now, I was the only one who got your message. If
you don't have a "Reply to all" button, make sure you put the php list
in the to or cc address.

-- 
If this is a mailing list: DO NOT TOP POST! why?:
http://www.caliburn.nl/topposting.html

Vote for PHP Color Coding (aka Syntax Highlighting) in Gmail! ->
http://gpcc.tijnema.info

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



Re: [PHP] is this a bug?

2007-08-20 Thread Thijs Lensselink
On Mon, 20 Aug 2007 02:24:49 -0300, Augusto Morais <[EMAIL PROTECTED]> wrote:
> I dont know what is happening...
> 
> 
> Can somebody clarify the situation for me?
> 
> 
> here is the situation:
> 
>i have 3 files:
> 
> class.php
> foo.php
> bar.php
> 
> // - class.php
> class globalactions {
> 
>   function include_file($module) {
>   if ($module) {
>   return 
> ("modules/".$module."/templates/".$module.".php");
>   } else { return include("modules/main/templates/index.php"); }
>   }
> }
> 
> 
> // - foo.php
> include "lib/clients.class.php";
> $clients = new clients(); //instatiating the clients class
> 
> 
> // - bar.php
> include 'class.php';
> $globalactions = new globalactions ();
> include $globalactions->include_file("foo");  //return ->
> "modules/foo/templates/foo.php"
> 
> var_dump($clients); //will return the object
> 
> 
> 
> OK. All this works. but i want make some changes.
> 
> Well.. What i want to do is this:
> 
> class.php:
> 
> change the line:
> return ("modules/".$module."/templates/".$module.".php");
> 
> to:
> return include ("modules/".$module."/templates/".$module.".php");
> 
> and in the bar.php:
> 
> 
> // - bar.php
> include 'class.php';
> $globalactions = new globalactions ();
> $globalactions->include_file("foo");  //return -> "include
> modules/foo/templates/foo.php"  // OK. This works.
> 
> var_dump($clients); //i dont get the object here. I got NULL!!! why?!?!!?
> 
> 
> 
> What is happening?
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

No this is not a bug. And it also has nothing todo with scoping.
The object "client" returns NULL. This can only happen if the object is not 
instantiated.

I guess the foo.php file is not included at all.

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



Re: [PHP] Is this a bug?

2008-08-29 Thread Robert Cummings
On Fri, 2008-08-29 at 10:40 +0300, Catalin Zamfir Alexandru, DATAGRAM
SRL wrote:
> Echo 'something';
> 
> Echo 'another thing';
> 
> Echo 'something '\;

I got the following output in both php5 and php4:

Warning: Unexpected character in input:  '\' (ASCII=92) state=1
in /home/rob/bleh.php on line 7
somethinganother thingsomething 

You might want to crank up your error reporting.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Is this a bug?

2008-08-29 Thread T Lensselink
Catalin Zamfir Alexandru, DATAGRAM SRL wrote:
> Hello guys,
>
> I've been stalking on the list for some time. Didn't have
> anything to report/talk, until now. I have a code like this, maybe you guys
> can reproduce it, with output buffering started:
>
> Echo 'something';
>
> Echo 'another thing';
>
> Echo 'something '\;
>
>  
>
> What happens is that ANYTHING that was echo'ed until that \,
> will not reach the buffer. Although, this should actually be a Parse Error,
> it isn't, it just echoes what was echoed after the god damned \. It took me
> two hours to find this typo in the code .
>
>  
>
> Can you guys reproduce the error? I can actually give you a
> link to the server where this code runs.
>
>
>   
The script doesn't cause a parse error Instead it throws a warning.

'PHP Warning:  Unexpected character in input:  '\' (ASCII=92) state=1 in'

Don't think it's a bug. And the reason there's no syntax error is
because the \ is a PHP
escape character.



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



RE: [PHP] Is this a bug?

2008-08-29 Thread Catalin Zamfir Alexandru, DATAGRAM SRL
I'm using a custom ob_handler (it's a MVC framework, we need this handler).
The ironic thing is that, executed once, the error doesn't show. Executed
twice, the error you're talking about shows. Executed 3rd ... the same as
the first execution. And I have my error_reporting to E_ALL. This happens
ONLY on this kind of error, any other type of error gets reported every
time.

Do you have any ideea what this error type is? E_WARNING? Maybe I
missed something ... And, shouldn't this be a parse error? Rather than a
warning?

-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 29, 2008 10:56 AM
To: Catalin Zamfir Alexandru, DATAGRAM SRL
Cc: php-general@lists.php.net
Subject: Re: [PHP] Is this a bug?

On Fri, 2008-08-29 at 10:40 +0300, Catalin Zamfir Alexandru, DATAGRAM
SRL wrote:
> Echo 'something';
> 
> Echo 'another thing';
> 
> Echo 'something '\;

I got the following output in both php5 and php4:

Warning: Unexpected character in input:  '\' (ASCII=92) state=1
in /home/rob/bleh.php on line 7
somethinganother thingsomething 

You might want to crank up your error reporting.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
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] Is this a bug?

2008-08-29 Thread Jochem Maas

T Lensselink schreef:

Catalin Zamfir Alexandru, DATAGRAM SRL wrote:

Hello guys,

I've been stalking on the list for some time. Didn't have
anything to report/talk, until now. I have a code like this, maybe you guys
can reproduce it, with output buffering started:

Echo 'something';

Echo 'another thing';

Echo 'something '\;

 


What happens is that ANYTHING that was echo'ed until that \,
will not reach the buffer. Although, this should actually be a Parse Error,
it isn't, it just echoes what was echoed after the god damned \. It took me
two hours to find this typo in the code .



ouch.
don't forget you can do:

$> php - l yourscript.php

to test for syntax errors (the warning does show up with this).

additionally a good syntax highlighting editor can help you to spot
stuff like this ... anything to stop the eyes from bleeding :/




Can you guys reproduce the error? I can actually give you a
link to the server where this code runs.


  

The script doesn't cause a parse error Instead it throws a warning.

'PHP Warning:  Unexpected character in input:  '\' (ASCII=92) state=1 in'

Don't think it's a bug. And the reason there's no syntax error is
because the \ is a PHP
escape character.


is this character ever valid as an escape character outside of a string?
if it is that's news to me and if it isn't then really it is a bug ...
it should be a straight up parse error ... chances are that it's down
to limitations in the lexer?

the output buffer handler that seems to be swallowing the warning every
second request  now that is weird.








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



Re: [PHP] Is this a bug?

2008-08-30 Thread Thijs Lensselink
Jochem Maas wrote:
> T Lensselink schreef:
>> Catalin Zamfir Alexandru, DATAGRAM SRL wrote:
>>> Hello guys,
>>>
>>> I've been stalking on the list for some time. Didn't
>>> have
>>> anything to report/talk, until now. I have a code like this, maybe
>>> you guys
>>> can reproduce it, with output buffering started:
>>>
>>> Echo 'something';
>>>
>>> Echo 'another thing';
>>>
>>> Echo 'something '\;
>>>
>>>  
>>>
>>> What happens is that ANYTHING that was echo'ed until
>>> that \,
>>> will not reach the buffer. Although, this should actually be a Parse
>>> Error,
>>> it isn't, it just echoes what was echoed after the god damned \. It
>>> took me
>>> two hours to find this typo in the code .
>>>
>
> ouch.
> don't forget you can do:
>
> $> php - l yourscript.php
>
> to test for syntax errors (the warning does show up with this).
>
> additionally a good syntax highlighting editor can help you to spot
> stuff like this ... anything to stop the eyes from bleeding :/
>
>
>>>
>>> Can you guys reproduce the error? I can actually
>>> give you a
>>> link to the server where this code runs.
>>>
>>>
>>>   
>> The script doesn't cause a parse error Instead it throws a warning.
>>
>> 'PHP Warning:  Unexpected character in input:  '\' (ASCII=92) state=1
>> in'
>>
>> Don't think it's a bug. And the reason there's no syntax error is
>> because the \ is a PHP
>> escape character.
>
> is this character ever valid as an escape character outside of a string?
> if it is that's news to me and if it isn't then really it is a bug ...
> it should be a straight up parse error ... chances are that it's down
> to limitations in the lexer?
>
> the output buffer handler that seems to be swallowing the warning every
> second request  now that is weird.
I don't think it should be valid outside a string. But PHP seems to see
this different.
The only reason i could think of. Is that the \ somehow is a registered
symbol. So it throws
a non fatal E_COMPILE_ERROR. Could be a bug. That's for the guys on
internals to decide.
I'd also expect a parse error.

With output buffering enabled i still get the same warning on every request.
>
>>
>>
>>
>
>


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



RE: [PHP] Is this a bug?

2008-08-31 Thread Catalin Zamfir Alexandru | KIT Software CAZ
I actually must say we have a special kind of output buffering that saves
all the content in an array like structure and outputs all content at the
end. This way we managed to have our coders work in a rather C/C++ like way,
where they can modify the rendered content anywhere in a script. The fact
that the error gets detected twice is maybe a weirdness in our output
handler, but as you guys already said, this should be detected actually as a
parse error.

About the editor, it's weird. We use Eclipse Europa (PDT Tools),
because they integrate superb with our SVN2WEB development schema (instant
web publish, SVN backup) and the error isn't highlighted in Eclipse. The
manual tells nothing about such a thing.

It's actually a weird glitch. Why: because if a PHP project decides
it wants some weird control over the output buffer, like we do right here
with our "delay output until the script ends" ideology, chances for such a
typo to cause headaches is great. I can see projects rendered useless for a
time, until the code is scanned for such a weirdness.

All in all, thanks guys for the time you took testing this. It seems
I must revise our output-handler, and do something to our Eclipse PDT set-up
so it can detect this as an error.

-Original Message-
From: Thijs Lensselink [mailto:[EMAIL PROTECTED] 
Sent: Saturday, August 30, 2008 3:25 PM
Cc: php-general@lists.php.net
Subject: Re: [PHP] Is this a bug?

Jochem Maas wrote:
> T Lensselink schreef:
>> Catalin Zamfir Alexandru, DATAGRAM SRL wrote:
>>> Hello guys,
>>>
>>> I've been stalking on the list for some time. Didn't
>>> have
>>> anything to report/talk, until now. I have a code like this, maybe
>>> you guys
>>> can reproduce it, with output buffering started:
>>>
>>> Echo 'something';
>>>
>>> Echo 'another thing';
>>>
>>> Echo 'something '\;
>>>
>>>  
>>>
>>> What happens is that ANYTHING that was echo'ed until
>>> that \,
>>> will not reach the buffer. Although, this should actually be a Parse
>>> Error,
>>> it isn't, it just echoes what was echoed after the god damned \. It
>>> took me
>>> two hours to find this typo in the code .
>>>
>
> ouch.
> don't forget you can do:
>
> $> php - l yourscript.php
>
> to test for syntax errors (the warning does show up with this).
>
> additionally a good syntax highlighting editor can help you to spot
> stuff like this ... anything to stop the eyes from bleeding :/
>
>
>>>
>>> Can you guys reproduce the error? I can actually
>>> give you a
>>> link to the server where this code runs.
>>>
>>>
>>>   
>> The script doesn't cause a parse error Instead it throws a warning.
>>
>> 'PHP Warning:  Unexpected character in input:  '\' (ASCII=92) state=1
>> in'
>>
>> Don't think it's a bug. And the reason there's no syntax error is
>> because the \ is a PHP
>> escape character.
>
> is this character ever valid as an escape character outside of a string?
> if it is that's news to me and if it isn't then really it is a bug ...
> it should be a straight up parse error ... chances are that it's down
> to limitations in the lexer?
>
> the output buffer handler that seems to be swallowing the warning every
> second request  now that is weird.
I don't think it should be valid outside a string. But PHP seems to see
this different.
The only reason i could think of. Is that the \ somehow is a registered
symbol. So it throws
a non fatal E_COMPILE_ERROR. Could be a bug. That's for the guys on
internals to decide.
I'd also expect a parse error.

With output buffering enabled i still get the same warning on every request.
>
>>
>>
>>
>
>


-- 
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] IS THIS A BUG?

2003-08-27 Thread Curt Zirzow
* Thus wrote Steve Todd ([EMAIL PROTECTED]):
> Is it possible to define a variable, such as:
> $foo = "bar";
>  
> and then do as follows to create a totally different variable:
> $$foo =  "text here";
>  
> this seems to mean $bar = "text here";.
>  
> Is this a bug or can we legally use it.

perfectly legal, its called a variable variable...

http://php.net/variables.variable


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



Re: [PHP] IS THIS A BUG?

2003-08-27 Thread John W. Holmes
Steve Todd wrote:

Is it possible to define a variable, such as:
$foo = "bar";
 
and then do as follows to create a totally different variable:
$$foo =  "text here";
 
this seems to mean $bar = "text here";.
 
Is this a bug or can we legally use it.
Yes it's legal.

http://us2.php.net/manual/en/language.variables.variable.php

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


Re: [PHP] IS THIS A BUG?

2003-08-27 Thread Chris Shiflett
--- Steve Todd <[EMAIL PROTECTED]> wrote:
> Is it possible to define a variable, such as:
> $foo = "bar";
>  
> and then do as follows to create a totally different variable:
> $$foo =  "text here";
>  
> this seems to mean $bar = "text here";.
>  
> Is this a bug or can we legally use it.

It is not a bug, but it's still PHP:

http://bbspot.com/News/2000/6/php_suspend.html

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

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



RE: [PHP] IS THIS A BUG?

2003-08-27 Thread Chris W. Parker
Steve Todd 
on Wednesday, August 27, 2003 1:28 PM said:

> Is this a bug or can we legally use it.

It's legal. And here is an article that explains it:

http://www.phphideout.com/articleview.php/5

(read near the bottom)


Chris.

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



Re: [PHP] IS THIS A BUG?

2003-08-27 Thread Chris Sherwood
No its not a bug

basically what you did was assign a value to a value of a variable

a $$ is how you access the value of a variable as a variable


- Original Message - 
From: "Steve Todd" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 27, 2003 1:27 PM
Subject: [PHP] IS THIS A BUG?


> Is it possible to define a variable, such as:
> $foo = "bar";
>  
> and then do as follows to create a totally different variable:
> $$foo =  "text here";
>  
> this seems to mean $bar = "text here";.
>  
> Is this a bug or can we legally use it.
>  
> Steve
> 

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



Re: [PHP] IS THIS A BUG?

2003-08-27 Thread Leif K-Brooks
Steve Todd wrote:

Is this a bug or can we legally use it.

Please RTFM before posting! http://php.net/variables.variable

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
to decrypt it will be prosecuted to the full extent of the law.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Is this a bug?

2005-01-13 Thread Jochem Maas
Rory McKinley wrote:
Hi
Probably a trivial question
While trying to use mysqli on my dev machine, PHP returns the following:
Fatal error: Trying to clone an uncloneable object of class mysqli
After STFW I have found a solution that involves swiching off 
compatibility with Zend Engine 1 in php.ini.

However, after going to bugs.php.net, it seems that it has not been 
logged as a bug.

So, the question would be - do I log it or am I wasting their time?
I think they will probably disregard it, I believe that when Ze1compat 
mode is on the object is at some time being truely copied where under 
'normal' situations (ie. using the ZE2 object model) assigning the 
object to another var will merely create a reference - since, 
apparently, creating a copy of the object is not allowed you get the 
error when the engine trys to clone it (when you assign the created 
object to another var, possibly when returning it from a function/method).

Also I recommend switching off ZE1Compat mode if you don't need - it 
means you get all the cool stuff from PHP5 - like proper object 
referencing (i.e. no more worries about using ampersand to pass objs by 
reference etc)


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


[PHP] Is this a bug with date() ?

2010-06-30 Thread Michael Alaimo
I understand that technically there are more than 52 weeks in a year. 
Well at least google says 1 year = 52.177457 weeks.

So I run the command:
php > echo date('W' , mktime(0, 0, 0, 1, 1, date('Y')));
53

As you can see the result is 53.

Any thoughts on this?

Mike

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



[PHP] Is this a bug in PHP 4.3.4?

2004-11-29 Thread Octavian Rasnita
Hi all,

I use the  following program:


...

EOF;

ob_flush();
}

function print_quotes () {
output_reset_rewrite_vars();

echo <<
...

EOF;
}

?>


The result printed is:

Content-type: text/html
X-Powered-By: PHP/4.3.4


...

...


Well, do you have any idea why PHP prints:



...instead of:



I have tried this program under Fedora Core 2 in command line mode and on an
Apache web server with the same results.

Do you have suggestions for making this program work and why does this
happen?

Thank you.

Teddy

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



Re: [PHP] Is this a bug in PHP 4.3.4?

2004-11-29 Thread Raditha Dissanayake
Octavian Rasnita wrote:
Hi all,
I use the  following program:
 


function print_quotes () {
output_reset_rewrite_vars();
echo <<
...

EOF;
}
I have tried this program under Fedora Core 2 in command line mode and on an
Apache web server with the same results.
Do you have suggestions for making this program work and why does this
happen?
 

I think the problem is with your 'here document' this is the traditional 
way of doing things in perl but in php you could  'go back into HTML. by 
using the '?>' sequence. Thus your program might become

function print_quotes () {
output_reset_rewrite_vars();
?>

...


}
There are pros and cons of both approach but the bit of code i have 
given will produce the expected result.

 


--
Raditha Dissanayake.
--
http://www.radinks.com/print/card-designer/ | Card Designer Applet
http://www.radinks.com/upload/  | Drag and Drop Upload 

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


Re: [PHP] Is this a bug in PHP 4.3.4?

2004-11-29 Thread Octavian Rasnita
Thank you. I will try that solution if it works, but the question still
remains...
Is PHP so buggy? The 'here document' should work without a problem in PHP
also.

My code works fine with PHP 5 (fortunately) under Windows, but it doesn't
work with PHP 4.3.4 under Linux.

I think I need to upgrade php under Linux also...

Teddy

- Original Message - 
From: "Raditha Dissanayake" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, November 29, 2004 5:29 PM
Subject: Re: [PHP] Is this a bug in PHP 4.3.4?


Octavian Rasnita wrote:

>Hi all,
>
>I use the  following program:
>
>
>

>function print_quotes () {
>output_reset_rewrite_vars();
>
>echo <<
>...
>
>EOF;
>}
>
>
>I have tried this program under Fedora Core 2 in command line mode and on
an
>Apache web server with the same results.
>
>Do you have suggestions for making this program work and why does this
>happen?
>
>
I think the problem is with your 'here document' this is the traditional
way of doing things in perl but in php you could  'go back into HTML. by
using the '?>' sequence. Thus your program might become

function print_quotes () {
output_reset_rewrite_vars();
 ?>
 
 ...
 
http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Is this a bug in PHP 4.3.4?

2004-11-29 Thread Greg Donald
On Mon, 29 Nov 2004 17:58:27 +0200, Octavian Rasnita <[EMAIL PROTECTED]> wrote:
> Is PHP so buggy? The 'here document' should work without a problem in PHP
> also.

The latest stable PHP 4 is rock solid from where I'm sitting.  We have
a bunch of Debian servers running 4.3.9 with no issues.

> My code works fine with PHP 5 (fortunately) under Windows, but it doesn't
> work with PHP 4.3.4 under Linux.
> 
> I think I need to upgrade php under Linux also...

I would defiantly upgrade.  Hundreds of bugs have been fixed from
4.3.4 -> 4.3.9.

http://www.php.net/ChangeLog-4.php


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



Re: [PHP] Is this a bug in PHP 4.3.4?

2004-11-29 Thread Greg Donald
On Mon, 29 Nov 2004 10:28:57 -0600, Greg Donald <[EMAIL PROTECTED]> wrote:
> I would defiantly upgrade.

Definitely too.  :)


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



Re: [PHP] Is this a bug in PHP 4.3.4?

2004-11-29 Thread Raditha Dissanayake
Octavian Rasnita wrote:
Thank you. I will try that solution if it works, but the question still
remains...
Is PHP so buggy? The 'here document' should work without a problem in PHP
also.
 

It probably wasn't a bug in php 4.3.4 but as greg has pointed out you 
probably should upgrade anyway. Here documents are pretty hard to work 
with at the best of times and it's quite easy to make a teeny weeny hard 
to detect typo.,

My code works fine with PHP 5 (fortunately) under Windows, but it doesn't
work with PHP 4.3.4 under Linux.
I think I need to upgrade php under Linux also...
 

--
Raditha Dissanayake.
--
http://www.radinks.com/print/card-designer/ | Card Designer Applet
http://www.radinks.com/upload/  | Drag and Drop Upload 

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


[PHP] Is this a bug?!!! I cna't believe! Sorry, if im wrong...

2005-01-30 Thread news.php.net
name = $str;
  }
 }

 $arr = array();

//Put to array to objects of class A,
// where their attribute A::a is assigned a different value
//objects are assigned to an array by reference

$a = &new A("qaz");
 $arr[0] = &$a;

 $a = &new A("wsx");
 $arr[1] = &$a;


//But watch the output!!!
// It is "(qaz)(qaz)", which means that the attribute of a first
// object assigned to array is outputted!!! WHY?!?!!!
 foreach($arr as $a)
 {
  echo "(".$a->name.")";
 }
?>

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



Re: [PHP] Is this a bug?!!! I cna't believe! Sorry, if im wrong...

2005-01-30 Thread Marek Kilimajer
No
news.php.net wrote:

 class A
 {
  var $name;
  function A($str)
  {
   $this->name = $str;
  }
 }
 $arr = array();
//Put to array to objects of class A,
// where their attribute A::a is assigned a different value
//objects are assigned to an array by reference
$a = &new A("qaz");
 $arr[0] = &$a;
$arr[0] and $a reference now the same variable
 $a = &new A("wsx");
by changing $a you also changed $arr[0]
 $arr[1] = &$a;
now $a, $arr[0] and $arr[1] reference the same variable, they just have 
different names.

More:
http://sk.php.net/manual/en/language.variables.php
http://sk.php.net/manual/en/language.references.php

//But watch the output!!!
// It is "(qaz)(qaz)", which means that the attribute of a first
// object assigned to array is outputted!!! WHY?!?!!!
 foreach($arr as $a)
 {
  echo "(".$a->name.")";
 }
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Is this a bug?!!! I cna't believe! Sorry, if im wrong...

2005-01-30 Thread news.php.net
> No
>
> news.php.net wrote:
>> >
>>  class A
>>  {
>>   var $name;
>>   function A($str)
>>   {
>>$this->name = $str;
>>   }
>>  }
>>
>>  $arr = array();
>>
>> //Put to array to objects of class A,
>> // where their attribute A::a is assigned a different value
>> //objects are assigned to an array by reference
>>
>> $a = &new A("qaz");
>>  $arr[0] = &$a;
>
> $arr[0] and $a reference now the same variable
>
>>
>>  $a = &new A("wsx");
>
> by changing $a you also changed $arr[0]

No. referencs are not pointers! Here in "  $a = &new A("wsx") " I assign $a
by reference, and now $a references the different location, and $arr[0]
references the same. Assigning $a by references doesnt affect $arr[0],
though the pointed to the same location before...
After all this is the prove:

This is my  previous assignment code:


 class A
 {
  var $name;
  function A($str)
  {
   $this->name = $str;
  }
 }

 $arr = array();

//Put to array to objects of class A,
// where their attribute A::a is assigned a different value
//objects are assigned to an array by reference

$a = &new A("qaz");
 $arr[0] = &$a;

 $a = &new A("wsx");
 $arr[1] = &$a;

//HERE IS THE PROVE
print_r($arr);
//Watch the OUTPUT... there are DIFFERENT objects laying in the array! This
is the point of my question...

// But if you do this:

 foreach($arr as $a)
 {
  echo "(".$a->name.")";
 }

// You see that iterating the objects it somehow references the same
object...
// or the same 'name' attrribute of the first object in the array...











>
>>  $arr[1] = &$a;
>
> now $a, $arr[0] and $arr[1] reference the same variable, they just have 
> different names.
>
> More:
> http://sk.php.net/manual/en/language.variables.php
> http://sk.php.net/manual/en/language.references.php
>
>>
>>
>> //But watch the output!!!
>> // It is "(qaz)(qaz)", which means that the attribute of a first
>> // object assigned to array is outputted!!! WHY?!?!!!
>>  foreach($arr as $a)
>>  {
>>   echo "(".$a->name.")";
>>  }
>> ?>
>>

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



Re: [PHP] Is this a bug?!!! I cna't believe! Sorry, if im wrong...

2005-01-30 Thread Jochem Maas
I did a little experimenting, and it looks like foreach is misbehaving,
but may I just don't get it, anyway check this out
(my php version and output are below):
class A { var $name; function A($str) { $this->name = $str; } }
// does not work as expected.
$arr = array();
$a = &new A("qaz");
$arr[0] = &$a;  unset($a);
$a = &new A("wsx"); print_r($a);
$arr[1] = &$a;  print_r($arr[1]);
print_r($arr);
foreach($arr as $a) { echo "(".$a->name.")"; }
echo "\n"; //^-- I thought this might be the problem, hence:
foreach($arr as $b) { echo "(".$b->name.")"; }
echo "\n--\n";
// works as expected
$arrB = array();
$arrB[0] = &new A("qaz");
$arrB[1] = &new A("wsx");
print_r($arrB);
foreach($arrB as $c) { echo "(".$c->name.")"; }
echo "\n--\n";
// works as expected
$arrC = array();
$f = new A("qaz");
$arrC[0] = $f;
$f = new A("wsx");
$arrC[1] = $f;
print_r($arrC);
foreach($arrC as $d) { echo "(".$d->name.")"; }
echo "\n--\n";
// works as expected
$arrD = array();
$h =& new A("qaz");
$arrD[0] = $h;
$h =& new A("wsx");
$arrD[1] = $h;
print_r($arrD);
foreach($arrD as $g) { echo "(".$g->name.")"; }
echo "\n--\n";
// both items in the array reference the
// second object (references $i) - this is correct
$arrE = array();
$i = new A("qaz");
$arrE[0] =& $i;
$i = new A("wsx");
$arrE[1] =& $i;
print_r($arrE);
foreach($arrE as $j) { echo "(".$j->name.")"; }
echo "\n--\n";

---
which gives the following output on
PHP 5.0.2 (cli) (built: Nov  9 2004 19:00:36):
A Object
(
[name] => wsx
)
A Object
(
[name] => wsx
)
Array
(
[0] => A Object
(
[name] => qaz
)
[1] => A Object
(
[name] => wsx
)
)
(qaz)(qaz)
(qaz)(qaz)
--
Array
(
[0] => A Object
(
[name] => qaz
)
[1] => A Object
(
[name] => wsx
)
)
(qaz)(wsx)
--
Array
(
[0] => A Object
(
[name] => qaz
)
[1] => A Object
(
[name] => wsx
)
)
(qaz)(wsx)
--
Array
(
[0] => A Object
(
[name] => qaz
)
[1] => A Object
(
[name] => wsx
)
)
(qaz)(wsx)
--
Array
(
[0] => A Object
(
[name] => wsx
)
[1] => A Object
(
[name] => wsx
)
)
(wsx)(wsx)
--
news.php.net wrote:
No
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Is this a bug?!!! I cna't believe! Sorry, if im wrong...

2005-01-30 Thread Santa
В сообщении от Воскресенье 30 Январь 2005 16:07 news.php.net написал(a):
> 
>  class A
>  {
>   var $name;
>   function A($str)
>   {
>$this->name = $str;
>   }
>  }
>
>  $arr = array();
>
> //Put to array to objects of class A,
> // where their attribute A::a is assigned a different value
> //objects are assigned to an array by reference
>
> $a = &new A("qaz");
>  $arr[0] = &$a;
>
>  $a = &new A("wsx");
>  $arr[1] = &$a;
>
>
> //But watch the output!!!
> // It is "(qaz)(qaz)", which means that the attribute of a first
> // object assigned to array is outputted!!! WHY?!?!!!
>  foreach($arr as $a)
>  {
>   echo "(".$a->name.")";
>  }
> ?>

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