[PHP] Strange error in PHP 4.3.4RC2

2003-10-26 Thread Fabio Rotondo
Hi,

I am experiencing a strange error while using PHP 4.3.4RC2.
In the apache2 log, I read:
fatal: cannot realloc() 1937201923 bytes.

I do NEVER try to allocate such memory.
I think the problem is related to some serialize/unserialize() code I am 
using (in fact, removing serialize/unserialize block makes the script 
work perfectly).
Is there anything I can do to test _exactly_ where the script bombs?

Ciao,

  Fabio

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


[PHP] Re: string concatenation from array

2003-08-14 Thread Fabio Rotondo
Micah Montoy wrote:
I'm having a bit of difficulty getting a string to attach to itself from an
array.  Here is the bit of code I'm working on.
$wresult = ;

 foreach ($search_string as $word_result){
  $wresult = $wresult $word_result;
 }
what about:

$wresult = join (  , $search_string );

Ciao,

  Fabio

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


[PHP] Strange problem in class creation

2003-08-14 Thread Fabio Rotondo
Hi all,

I have encountered a tricky problem with PHP 4.3.1 (installed with 
SuSE 8.2).
I don't know if it is a bug or not. Maybe is just me missing something.

What I'd like to do is to pass a reference of base_class instance to the
constructor of second_class (so that the newly created second_class 
instance can
call methods from the base_class instance.
It seems that if base_class constructor directly calls its method 
create() (that is
responsible of creating the second_class instance, passing _$this_ as 
constructor
argument) the second_class gets a copy of base_class instance and 
not the real thing.

To test it, I have added an array ($arr) in the base_class and set a 
value into it.
If second_class really have a reference to the real base_class 
instance, it should be
able to print its contents, but this just doesn't work.

Please, notice that if in the following code you remove the line 
$this-create()
in the base_class constructor and add the commented line in the main 
body, everything
works fine.

What I am really missing?

Please, help!

Ciao,

  Fabio

 CODE STARTS HERE --
?php
class base_class
{
var $arr;
var $class;
function base_class ()
{
$this-arr = array ();
$this-class = false;
// it seems to create another instance of base_class
$this-create ();   // this line does not work
}
function set ( $val )
{
$this-arr []  = $val;
}
function create ()
{
$this-class = new second_class ( $this );
}
function test ()
{
$this-class-dump ();
}
}
class second_class
{
function second_class (  $main_class )
{
$this-main_class =  $main_class;
}
function dump ()
{
print_r ( $this-main_class-arr );
}
}
$b = new base_class ();
// $b-create ();   // This line works as expected
$b-set ( ciao );
$b-test ();
print br /;
print_r ( $b-arr );
?
 END CODE -
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Strange problem in class creation

2003-08-14 Thread Fabio Rotondo
Mukul Sabharwal wrote:

And the error is strange because you're doing
something strange!
I don't think I'm doing anything strange. What I have exposed here is a 
simplification of my own class loader. I have the main class that must 
load (include and then instance) other PHP classes.
The problem is that if I do instance other classes in the loader 
constructor they get a copy of the loader instance and not the real 
instance reference.

[some your code snipped]
$base = new base_class;
$second = new second_class($base);
$second-foo-some = 100;
// here it is, base_class' some is accessible
I know. If you give a closer look to my own code, you'll see that there 
is a line (commented) doing almost the same thing as you. But I need 
something else.

Infact, look at the end of my code, there are these two lines:

$b = new base_class ();
// $b-create ();   // This line works
if I instance the base_class and outside the constructor i do the create 
(as shown in the second line) everything works. And I am actually just 
sending ($this) as the argument (look inside the create method code),
in exactly the same way I was doing in the base_class constructor.
The problem is that inside the constructur THE SAME CODE DOES NOT WORK.

I think it's a bug. I have worked around it by doing the two calls, but 
I would like to know if it is a real bug or just me doing something wrong.

Ciao,

  Fabio

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


[PHP] Re: Cannot add header information - headers already sent

2003-08-14 Thread Fabio Rotondo
Frederik Feys wrote:

Hi Frederik,

Warning: Cannot add header information - headers already sent by (output
started at
/usr/local/www/vhosts/aurelis.org/htdocs/header_aurelis.php:95) in
/usr/local/www/vhosts/aurelis.org/htdocs/store/includes/functions/get_ca
rtID.php on line 14

Can anyone shed some light on this?
You already have had the right answer, but I think you could consider 
adding this line at the top of your PHP script:

ob_start( ob_gzhandler );

this enables HTML compression (on browsers that support it) and allows a 
much more flexible headers handling because text is sent back to the 
browser when your page is complete.

Ciao,

  Fabio

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